aggregate

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2025 License: AGPL-3.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoTerm added in v1.1.0

func AutoTerm(ctx context.Context, op string, threshold float64, wantSamples int, minDur time.Duration, updates chan<- UpdateReq) context.Context

AutoTerm allows to set auto-termination on a context.

func BPSorOPS

func BPSorOPS(bps, ops float64) string

BPSorOPS returns bytes per second if non zero otherwise operations per second as human readable string.

func Compare added in v1.1.3

func Compare(before, after *LiveAggregate, op string) (*bench.Comparison, error)

func LiveCollector added in v1.1.0

func LiveCollector(ctx context.Context, updates chan UpdateReq, clientID string, extra []chan<- bench.Operation) bench.Collector

LiveCollector return a collector, and a channel that will return the current aggregate on the channel whenever it is requested.

func RequestAnalysisHostsMultiSized

func RequestAnalysisHostsMultiSized(o bench.Operations) map[string]RequestSizeRange

RequestAnalysisHostsMultiSized performs host analysis where objects have different sizes.

func RequestAnalysisHostsSingleSized

func RequestAnalysisHostsSingleSized(o bench.Operations) map[string]SingleSizedRequests

RequestAnalysisHostsSingleSized performs host analysis where all objects have equal size.

Types

type Aggregated

type Aggregated struct {
	// MixedServerStats and MixedThroughputByHost is populated only when data is mixed.
	MixedServerStats      *Throughput           `json:"mixed_server_stats,omitempty"`
	MixedThroughputByHost map[string]Throughput `json:"mixed_throughput_by_host,omitempty"`
	Type                  string                `json:"type"`
	Operations            []Operation           `json:"operations,omitempty"`
	Mixed                 bool                  `json:"mixed"`
}

Aggregated contains aggregated data for a single benchmark run.

func Aggregate

func Aggregate(o bench.Operations, opts Options) Aggregated

Aggregate returns statistics when only a single operation was running concurrently.

type LiveAggregate added in v1.1.0

type LiveAggregate struct {
	Title string
	// Total requests
	TotalRequests int `json:"total_requests"`
	// Total objects
	TotalObjects int `json:"total_objects"`
	// Total errors
	TotalErrors int `json:"total_errors"`
	// Total bytes
	TotalBytes int64 `json:"total_bytes"`
	// Concurrency is the number of threads seen.
	Concurrency int `json:"concurrency"`

	// Unfiltered start time of this operation segment.
	StartTime time.Time `json:"start_time"`
	// Unfiltered end time of this operation segment.
	EndTime time.Time `json:"end_time"`

	// Subset of errors.
	FirstErrors []string `json:"first_errors"`
	// Numbers of hosts
	Hosts MapAsSlice `json:"hosts"`
	// Number of warp clients.
	Clients MapAsSlice `json:"clients"`

	// Throughput information.
	Throughput Throughput `json:"throughput"`

	// ThroughputByHost information. Without segments.
	ThroughputByHost map[string]Throughput `json:"throughput_by_host"`

	// ThroughputByClient information. Without segments.
	ThroughputByClient map[string]Throughput `json:"throughput_by_client"`

	// Requests segmented.
	// Indexed by client.
	Requests map[string]RequestSegments `json:"requests_by_client"`
	// contains filtered or unexported fields
}

func (*LiveAggregate) Add added in v1.1.0

func (l *LiveAggregate) Add(o bench.Operation)

Add operation to aggregate.

func (*LiveAggregate) Finalize added in v1.1.0

func (l *LiveAggregate) Finalize()

func (*LiveAggregate) Merge added in v1.1.0

func (l *LiveAggregate) Merge(l2 LiveAggregate)

Merge l2 into l.

func (LiveAggregate) Report added in v1.1.0

func (l LiveAggregate) Report(op string, o ReportOptions) string

func (LiveAggregate) Update added in v1.1.0

func (l LiveAggregate) Update() LiveAggregate

Update returns a temporary update without finalizing. The update will have no references to the live version.

type MapAsSlice added in v1.1.0

type MapAsSlice map[string]struct{}

MapAsSlice is a key-only map that is serialized as an array.

func (*MapAsSlice) Add added in v1.1.0

func (m *MapAsSlice) Add(k string)

Add value

func (*MapAsSlice) AddMap added in v1.1.0

func (m *MapAsSlice) AddMap(other MapAsSlice)

AddMap adds another map.

func (*MapAsSlice) AddSlice added in v1.1.0

func (m *MapAsSlice) AddSlice(other []string)

AddSlice adds a slice.

func (*MapAsSlice) Clone added in v1.1.0

func (m *MapAsSlice) Clone() MapAsSlice

Clone returns a clone.

func (MapAsSlice) MarshalJSON added in v1.1.0

func (m MapAsSlice) MarshalJSON() ([]byte, error)

MarshalJSON provides output as JSON.

func (*MapAsSlice) SetSlice added in v1.1.0

func (m *MapAsSlice) SetSlice(v []string)

SetSlice replaces the value with the content of a slice.

func (MapAsSlice) Slice added in v1.1.0

func (m MapAsSlice) Slice() []string

Slice returns the keys as a sorted slice.

func (*MapAsSlice) UnmarshalJSON added in v1.1.0

func (m *MapAsSlice) UnmarshalJSON(b []byte) error

UnmarshalJSON reads an array of strings and sets them as keys in the map.

type MultiSizedRequests

type MultiSizedRequests struct {
	// ByHost contains request information by host.
	// This data is not segmented.
	ByHost map[string]RequestSizeRange `json:"by_host,omitempty"`

	// BySize contains request times separated by sizes
	BySize RequestSizeRanges `json:"by_size"`

	// Total number of requests.
	Requests int `json:"requests"`

	// Average object size
	AvgObjSize int64 `json:"avg_obj_size"`

	// Skipped if too little data.
	Skipped bool `json:"skipped,omitempty"`

	// MergedEntries is a counter for the number of merged entries contained in this result.
	MergedEntries int `json:"merged_entries"`
}

MultiSizedRequests contains statistics when objects have the same different size.

func RequestAnalysisMultiSized

func RequestAnalysisMultiSized(o bench.Operations, allThreads bool) *MultiSizedRequests

RequestAnalysisMultiSized performs analysis where objects have different sizes.

type Operation

type Operation struct {
	// Throughput information.
	Throughput Throughput `json:"throughput"`
	// Unfiltered start time of this operation segment.
	StartTime time.Time `json:"start_time"`
	// Unfiltered end time of this operation segment.
	EndTime time.Time `json:"end_time"`
	// Throughput by host.
	ThroughputByHost map[string]Throughput `json:"throughput_by_host"`
	// Populated if requests are of difference object sizes.
	MultiSizedRequests *MultiSizedRequests `json:"multi_sized_requests,omitempty"`
	// Populated if requests are all of same object size.
	SingleSizedRequests *SingleSizedRequests `json:"single_sized_requests,omitempty"`
	// Operation type
	Type string `json:"type"`
	// HostNames are sorted names of hosts
	HostNames []string `json:"host_names"`
	// Subset of errors.
	FirstErrors []string `json:"first_errors"`
	// Numbers of hosts
	Hosts int `json:"hosts"`
	// Number of warp clients.
	Clients int `json:"clients"`
	// Concurrency - total number of threads running.
	Concurrency int `json:"concurrency"`
	// Total errors recorded.
	Errors int `json:"errors"`
	// Objects per operation.
	ObjectsPerOperation int `json:"objects_per_operation"`
	// N is the number of operations.
	N int `json:"n"`
	// Skipped if too little data
	Skipped bool `json:"skipped"`
}

Operation returns statistics for a single operation type.

type Options added in v0.3.25

type Options struct {
	DurFunc     SegmentDurFn
	SkipDur     time.Duration
	Prefiltered bool
}

type Realtime added in v1.1.0

type Realtime struct {
	DataVersion int    `json:"v"`
	Commandline string `json:"commandline"`
	Final       bool   `json:"final"`
	WarpVersion string `json:"warp_version,omitempty"`
	WarpCommit  string `json:"warp_commit,omitempty"`
	WarpDate    string `json:"warp_date,omitempty"`

	Total    LiveAggregate             `json:"total"`
	ByOpType map[string]*LiveAggregate `json:"by_op_type,omitempty"`
	// These are really not used.
	ByHost        map[string]*LiveAggregate         `json:"by_host,omitempty"`
	ByObjLog2Size map[int]*LiveAggregate            `json:"by_obj_log_2_size,omitempty"`
	ByClient      map[string]*LiveAggregate         `json:"by_client,omitempty"`
	ByCategory    map[bench.Category]*LiveAggregate `json:"by_category,omitempty"`
}

Realtime is a collection of realtime aggregated data.

func Live added in v1.1.0

func Live(ops <-chan bench.Operation, updates chan UpdateReq, clientID string, extra []chan<- bench.Operation) *Realtime

Live collects operations and update requests.

func (*Realtime) Finalize added in v1.1.0

func (r *Realtime) Finalize()

func (*Realtime) Merge added in v1.1.0

func (r *Realtime) Merge(other *Realtime)

func (*Realtime) Report added in v1.1.0

func (r *Realtime) Report(o ReportOptions) *bytes.Buffer

type ReportOptions added in v1.1.0

type ReportOptions struct {
	Details  bool
	Color    bool
	SkipReqs bool
	OnlyOps  map[string]struct{}
}

ReportOptions provides options to report generation.

type RequestSegment added in v1.1.0

type RequestSegment struct {
	StartTime time.Time `json:"start_time"`
	EndTime   time.Time `json:"end_time"`

	// Populated if requests are of difference object sizes.
	Multi *MultiSizedRequests `json:"multi_sized_requests,omitempty"`

	// Populated if requests are all of same object size.
	Single *SingleSizedRequests `json:"single_sized_requests,omitempty"`
}

type RequestSegments added in v1.1.0

type RequestSegments []RequestSegment

type RequestSizeRange

type RequestSizeRange struct {
	// Time to first byte if applicable.
	FirstByte *TTFB `json:"first_byte,omitempty"`

	// FirstAccess is filled if the same object is accessed multiple times.
	// This records the first touch of the object.
	FirstAccess *RequestSizeRange `json:"first_access,omitempty"`

	MinSizeString string `json:"min_size_string"`
	MaxSizeString string `json:"max_size_string"`

	// BpsPct is BPS percentiles.
	BpsPct *[101]float64 `json:"bps_percentiles,omitempty"`

	BpsMedian         float64 `json:"bps_median"`
	AvgDurationMillis float64 `json:"avg_duration_millis"`

	// Stats:
	BpsAverage float64 `json:"bps_average"`
	// Number of requests in this range.
	Requests   int     `json:"requests"`
	Bps90      float64 `json:"bps_90"`
	Bps99      float64 `json:"bps_99"`
	BpsFastest float64 `json:"bps_fastest"`
	BpsSlowest float64 `json:"bps_slowest"`

	// Average payload size of requests in bytes.
	AvgObjSize int `json:"avg_obj_size"`
	// Maximum size in request size range (not included).
	MaxSize int `json:"max_size"`
	// Minimum size in request size range.
	MinSize int `json:"min_size"`

	// MergedEntries is a counter for the number of merged entries contained in this result.
	MergedEntries int `json:"merged_entries"`
}

func (RequestSizeRange) String added in v1.1.0

func (s RequestSizeRange) String() string

func (RequestSizeRange) StringByN added in v1.1.0

func (s RequestSizeRange) StringByN() string

type RequestSizeRanges added in v1.1.0

type RequestSizeRanges []RequestSizeRange

RequestSizeRanges is an array of RequestSizeRange

func (RequestSizeRanges) FindMatching added in v1.1.0

func (r RequestSizeRanges) FindMatching(want RequestSizeRange) (v *RequestSizeRange, found bool)

FindMatching will find a matching range, or create a new range. New entries will not me added to r.

func (RequestSizeRanges) SortbySize added in v1.1.0

func (r RequestSizeRanges) SortbySize()

SortbySize will sort the ranges by size.

type SegmentDurFn added in v0.3.24

type SegmentDurFn func(total time.Duration) time.Duration

SegmentDurFn accepts a total time and should return the duration used for each segment.

type SegmentSmall

type SegmentSmall struct {
	// Start time of the segment.
	Start time.Time `json:"start"`
	// Bytes per second during the time segment.
	BPS float64 `json:"bytes_per_sec"`

	// Objects per second during the time segment.
	OPS float64 `json:"obj_per_sec"`

	// Errors logged during the time segment.
	Errors int `json:"errors,omitempty"`
}

SegmentSmall represents a time segment of the run. Length of the segment is defined elsewhere.

func (SegmentSmall) LongSeg added in v1.1.3

func (s SegmentSmall) LongSeg(segdur time.Duration) bench.Segment

func (SegmentSmall) StringLong

func (s SegmentSmall) StringLong(d time.Duration, details bool) string

StringLong returns a long string representation of the segment.

type SegmentsSmall added in v1.1.0

type SegmentsSmall []SegmentSmall

func (SegmentsSmall) Median added in v1.1.0

func (s SegmentsSmall) Median(m float64) SegmentSmall

Median returns the m part median. m is clamped to the range 0 -> 1.

func (*SegmentsSmall) Merge added in v1.1.0

func (s *SegmentsSmall) Merge(other SegmentsSmall)

Merge 'other' into 't'. Will mutate (re-sort) both segments. Segments must have same time alignment.

func (SegmentsSmall) SortByObjsPerSec added in v1.1.0

func (s SegmentsSmall) SortByObjsPerSec()

SortByObjsPerSec sorts the segments by the number of objects processed in the segment. Lowest first.

func (SegmentsSmall) SortByStartTime added in v1.1.0

func (s SegmentsSmall) SortByStartTime()

SortByStartTime sorts the segments by the start time. Earliest first.

func (SegmentsSmall) SortByThroughput added in v1.1.0

func (s SegmentsSmall) SortByThroughput()

SortByThroughput sorts the segments by throughput. Slowest first.

type SingleSizedRequests

type SingleSizedRequests struct {
	// Request times by host.
	ByHost map[string]SingleSizedRequests `json:"by_host,omitempty"`

	// FirstAccess is filled if the same object is accessed multiple times.
	// This records the first access of the object.
	FirstAccess *SingleSizedRequests `json:"first_access,omitempty"`

	// FirstAccess is filled if the same object is accessed multiple times.
	// This records the last access of the object.
	LastAccess *SingleSizedRequests `json:"last_access,omitempty"`

	// Time to first byte if applicable.
	FirstByte *TTFB `json:"first_byte,omitempty"`

	// Host names, sorted.
	HostNames MapAsSlice `json:"host_names,omitempty"`

	// DurPct is duration percentiles (milliseconds).
	DurPct *[101]float64 `json:"dur_percentiles_millis,omitempty"`

	// Median request duration.
	DurMedianMillis float64 `json:"dur_median_millis"`

	// Fastest request time.
	FastestMillis float64 `json:"fastest_millis"`

	// Slowest request time.
	SlowestMillis float64 `json:"slowest_millis"`

	// StdDev is the standard deviation of requests.
	StdDev float64 `json:"std_dev_millis"`

	// 99% request time.
	Dur99Millis float64 `json:"dur_99_millis"`

	// 90% request time.
	Dur90Millis float64 `json:"dur_90_millis"`

	// Average request duration.
	DurAvgMillis float64 `json:"dur_avg_millis"`

	// Total number of requests.
	Requests int `json:"requests"`

	// Object size per operation. Can be 0.
	ObjSize int64 `json:"obj_size"`

	// Skipped if too little data.
	Skipped bool `json:"skipped,omitempty"`

	// MergedEntries is a counter for the number of merged entries contained in this result.
	MergedEntries int `json:"merged_entries"`
}

SingleSizedRequests contains statistics when all objects have the same size.

func RequestAnalysisSingleSized

func RequestAnalysisSingleSized(o bench.Operations, allThreads bool) *SingleSizedRequests

RequestAnalysisSingleSized performs analysis where all objects have equal size.

func (SingleSizedRequests) StringByN added in v1.1.0

func (a SingleSizedRequests) StringByN() string

type TTFB

type TTFB struct {
	AverageMillis     float64       `json:"average_millis"`
	FastestMillis     float64       `json:"fastest_millis"`
	P25Millis         float64       `json:"p25_millis"`
	MedianMillis      float64       `json:"median_millis"`
	P75Millis         float64       `json:"p75_millis"`
	P90Millis         float64       `json:"p90_millis"`
	P99Millis         float64       `json:"p99_millis"`
	SlowestMillis     float64       `json:"slowest_millis"`
	StdDevMillis      float64       `json:"std_dev_millis"`
	PercentilesMillis *[101]float64 `json:"percentiles_millis,omitempty"`
}

TTFB contains times to first byte if applicable.

func TtfbFromBench

func TtfbFromBench(t bench.TTFB) *TTFB

TtfbFromBench converts from bench.TTFB

func (*TTFB) AsBench added in v1.1.3

func (t *TTFB) AsBench(byN int) bench.TTFB

AsBench converts to bench.TTFB. Provide the byN value to scale the values (typically merged count).

func (TTFB) String

func (t TTFB) String() string

String returns a human printable version of the time to first byte.

func (TTFB) StringByN added in v1.1.0

func (t TTFB) StringByN(n int) string

type Throughput

type Throughput struct {
	// Start time of the measurement.
	StartTime time.Time `json:"start_time"`
	// End time of the measurement.
	EndTime time.Time `json:"end_time"`
	// Time segmented throughput summary.
	Segmented *ThroughputSegmented `json:"segmented,omitempty"`
	// Errors recorded.
	Errors int `json:"errors"`
	// Time period of the throughput measurement.
	MeasureDurationMillis int `json:"measure_duration_millis"`
	// Total bytes.
	Bytes float64 `json:"bytes"`
	// Total objects
	Objects float64 `json:"objects"`
	// Number of full operations
	Operations int `json:"ops"`
}

Throughput contains throughput.

func (Throughput) Add added in v1.1.0

func (Throughput) BytesPS added in v1.1.0

func (t Throughput) BytesPS() bench.Throughput

BytesPS returns the bytes per second throughput for the time segment.

func (*Throughput) Merge added in v1.1.0

func (t *Throughput) Merge(other Throughput)

Merge currently running measurements.

func (Throughput) ObjectsPS added in v1.1.0

func (t Throughput) ObjectsPS() float64

ObjectsPS returns the objects per second for the segment.

func (Throughput) String

func (t Throughput) String() string

String returns a string representation of the segment

func (Throughput) StringDetails added in v0.3.18

func (t Throughput) StringDetails(details bool) string

StringDetails returns a detailed string representation of the segment

func (Throughput) StringDuration added in v0.3.21

func (t Throughput) StringDuration() string

StringDuration returns a string representation of the segment duration

type ThroughputSegmented

type ThroughputSegmented struct {
	// Start time of fastest time segment.
	FastestStart time.Time `json:"fastest_start"`
	// 50% Median....
	MedianStart time.Time `json:"median_start"`
	// Slowest ...
	SlowestStart time.Time `json:"slowest_start"`
	// Will contain how segments are sorted.
	// Will be 'bps' (bytes per second) or 'ops' (objects per second).
	SortedBy string `json:"sorted_by"`

	// All segments, sorted
	Segments SegmentsSmall `json:"segments"`

	// Time of each segment.
	SegmentDurationMillis int `json:"segment_duration_millis"`

	// Fastest segment bytes per second. Can be 0. In that case segments are sorted by objects per second.
	FastestBPS float64 `json:"fastest_bps"`
	// Fastest segment in terms of objects per second.
	FastestOPS float64 `json:"fastest_ops"`
	MedianBPS  float64 `json:"median_bps"`
	MedianOPS  float64 `json:"median_ops"`
	SlowestBPS float64 `json:"slowest_bps"`
	SlowestOPS float64 `json:"slowest_ops"`
}

ThroughputSegmented contains time segmented throughput statics.

func (*ThroughputSegmented) Merge added in v1.1.0

func (t *ThroughputSegmented) Merge(other ThroughputSegmented)

type UpdateReq added in v1.1.0

type UpdateReq struct {
	C     chan<- *Realtime `json:"-"`
	Reset bool             `json:"reset"` // Does not return result.
	Final bool             `json:"final"` // Blocks until final value is ready.
}

UpdateReq is a request for an update. The latest will be sent on the provided channel, or nil if none is available yet. If the provided channel blocks no update will be sent.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL