Documentation
¶
Overview ¶
Internal package used to measuring and benchmarking of the discipline.
Index ¶
- Variables
- func CompareItem(first, second Measure) int
- func CompareTime(first, second Measure) int
- func KeepReceived(item Measure) bool
- type Benchmarker
- type Discipline
- type Kind
- type Measure
- type Measurer
- func (msr *Measurer) AddDelay(priority uint, delay time.Duration)
- func (msr *Measurer) AddWaitDevastation(priority uint)
- func (msr *Measurer) AddWrite(priority, quantity uint)
- func (msr *Measurer) AddWriteWithDelay(priority, quantity uint, delay time.Duration)
- func (msr *Measurer) HandlersQuantity() uint
- func (msr *Measurer) Inputs() map[uint]<-chan uint
- func (msr *Measurer) Play(discipline Discipline[uint]) ([]Measure, error)
- func (msr *Measurer) SetProcessingDuration(priority uint, duration time.Duration)
Constants ¶
This section is empty.
Variables ¶
var ( ErrDataMixedBetweenPriorities = errors.New("data is mixed between priorities") ErrDataPartiallyLost = errors.New("data is partially lost") ErrHandlersQuantityZero = errors.New("quantity of data handlers is zero") ErrMeasureDuplicated = errors.New("measure is duplicated") ErrMeasurementsIsIncomplete = errors.New("measurements is incomplete") ErrUnexpectedMeasureKind = errors.New("unexpected kind of measure is received") )
Functions ¶
func CompareItem ¶
Compare function for sorting measurements by data item.
func CompareTime ¶
Compare function for sorting measurements by time.
func KeepReceived ¶
Delete function that keeps only measurements of the Received kind.
Types ¶
type Benchmarker ¶
type Benchmarker struct {
// contains filtered or unexported fields
}
Used to benchmark discipline.
func NewBenchmarker ¶
func NewBenchmarker(handlersQuantity uint, inputCapacity ...uint) (*Benchmarker, error)
Creates Benchmarker instance.
If the capacity of the input (for the discipline) channels is not specified, then the capacity of each channel will be equal to the quantity of data items that will be written to it.
When specifying multiple input channel capacities, the value of the first one will be used.
func (*Benchmarker) AddItems ¶
func (bnch *Benchmarker) AddItems(priority, quantity uint)
Increases quantity of data items that will be written to the input (for the discipline) channel of the specified priority.
func (*Benchmarker) HandlersQuantity ¶
func (bnch *Benchmarker) HandlersQuantity() uint
Returns the quantity of data handlers specified when the instance was created.
func (*Benchmarker) Inputs ¶
func (bnch *Benchmarker) Inputs() map[uint]<-chan uint
Recreates the input (for the discipline) channels where data items will be written.
Must be called before Benchmarker.Play.
func (*Benchmarker) Play ¶
func (bnch *Benchmarker) Play(discipline Discipline[uint])
Writes data items to the input (for the discipline) channels and reads data items from the output channel of the discipline.
Must be called after Benchmarker.Inputs.
type Discipline ¶
type Discipline[Type any] interface { Err() <-chan error Output() <-chan types.Prioritized[Type] Release(priority uint) }
Interface of priority discipline.
type Kind ¶
type Kind int
Type of one measuring. Specifies the position of the measurement in the processing sequence of the data item received from the discipline.
type Measure ¶
type Measure struct { // Data item received from the discipline Item uint // Position of the measurement in the processing sequence of the data item Kind Kind // Priority of data item Priority uint // Relative time of measurement execution Time time.Duration }
Describes one measuring.
type Measurer ¶
type Measurer struct {
// contains filtered or unexported fields
}
Used to measuring discipline.
func NewMeasurer ¶
Creates Measurer instance.
If the capacity of the input (for the discipline) channels is not specified, then the capacity of each channel will be equal to the quantity of data handlers.
When specifying multiple input channel capacities, the value of the first one will be used.
func (*Measurer) AddWaitDevastation ¶
Adds to the actions list a waiting for the input (for the discipline) channel to be devastated.
func (*Measurer) AddWrite ¶
Adds to the actions list a write of the specified quantity of data items to the input (for the discipline) channel of the specified priority.
func (*Measurer) AddWriteWithDelay ¶
Adds to the actions list a write of the specified quantity of data items to the input (for the discipline) channel of the specified priority.
Before writing each data item, the specified delay occurs.
func (*Measurer) HandlersQuantity ¶
Returns the quantity of data handlers specified when the instance was created.
func (*Measurer) Inputs ¶
Recreates the input (for the discipline) channels where data items will be written.
Must be called before Measurer.Play.
func (*Measurer) Play ¶
func (msr *Measurer) Play(discipline Discipline[uint]) ([]Measure, error)
Writes data items to the input (for the discipline) channels, reads data items from the output channel of the discipline and collects measurements about the time it takes to receive, process and release data items.
Must be called after Measurer.Inputs.