bench

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDurableConsumerName = "nats-bench"
	DefaultStreamName          = "benchstream"
	DefaultBucketName          = "benchbucket"
	DefaultServiceName         = "nats-bench-service"
	DefaultServiceVersion      = "1.0.0"
	TypeCorePub                = "pub"
	TypeCoreSub                = "sub"
	TypeServiceRequest         = "request"
	TypeServiceServe           = "reply"
	TypeJSPubSync              = "jsyncpub"
	TypeJSPubAsync             = "jsasyncpub"
	TypeJSPubBatch             = "jsbatchpub"
	TypeJSOrdered              = "jsordered"
	TypeJSConsume              = "jsconsume"
	TypeJSFetch                = "jsfetch"
	TypeJSGetSync              = "jsgetdirectsync"
	TypeJSGetDirectBatched     = "jsgetdirectbatch"
	TypeOldJSOrdered           = "oldjsordered"
	TypeOldJSPush              = "oldjspush"
	TypeOldJSPull              = "oldjspull"
	TypeKVPut                  = "kvput"
	TypeKVGet                  = "kvget"
	AckModeNone                = "none"
	AckModeAll                 = "all"
	AckModeExplicit            = "explicit"
)

Variables

This section is empty.

Functions

func AvgLatency added in v0.3.1

func AvgLatency(latencies []uint64) float64

AvgLatency returns the average latency in microseconds

func GetBenchTypeLabel

func GetBenchTypeLabel(benchType string) string

func MaxLatency added in v0.3.1

func MaxLatency(latencies []uint64) float64

MaxLatency returns the maximum latency in microseconds

func MinLatency added in v0.3.1

func MinLatency(latencies []uint64) float64

MinLatency returns the minimum latency in microseconds

func PercentileLatency added in v0.3.1

func PercentileLatency(latencies []uint64, percentile float64) float64

PercentileLatency returns the given percentile latency in microseconds

func StdLatency added in v0.3.1

func StdLatency(latencies []uint64) float64

StdLatency returns the standard deviation of the latencies in microseconds

Types

type BenchSample

type BenchSample struct {
	// contains filtered or unexported fields
}

A BenchSample for a particular client

func NewSample

func NewSample(jobCount int, msgSize int, start, end time.Time, latencies []uint64, nc *nats.Conn) *BenchSample

NewSample creates a new BenchSample initialized to the provided values. The nats.Conn information captured

func (*BenchSample) Duration

func (s *BenchSample) Duration() time.Duration

Duration that the BenchSample was active

func (*BenchSample) Rate

func (s *BenchSample) Rate() int64

Rate of messages in the job per second

func (*BenchSample) String

func (s *BenchSample) String() string

String generates a human-readable report of the BenchSample

func (*BenchSample) Throughput

func (s *BenchSample) Throughput() float64

Throughput of bytes per second

type BenchSampleGroup

type BenchSampleGroup struct {
	BenchSample
	// contains filtered or unexported fields
}

BenchSampleGroup for a number of samples, the group is a BenchSample itself aggregating the values the samples

func NewSampleGroup

func NewSampleGroup() *BenchSampleGroup

NewSampleGroup initializer

func (*BenchSampleGroup) AddSample

func (sg *BenchSampleGroup) AddSample(e *BenchSample)

AddSample adds a BenchSample to the SampleGroup. After adding a BenchSample it shouldn't be modified.

func (*BenchSampleGroup) AvgMsgRate

func (sg *BenchSampleGroup) AvgMsgRate() int64

AvgMsgRate returns the average of all the message rates in the SampleGroup

func (*BenchSampleGroup) HasSamples

func (sg *BenchSampleGroup) HasSamples() bool

HasSamples returns true if the group has samples

func (*BenchSampleGroup) LatencyStatistics

func (sg *BenchSampleGroup) LatencyStatistics() string

LatencyStatistics prints statistics for the average latencies in microseconds of the BenchSample group (min, average, max and standard deviation)

func (*BenchSampleGroup) MaxLatency

func (sg *BenchSampleGroup) MaxLatency() uint64

MaxLatency returns the largest average latency in microseconds in the SampleGroup

func (*BenchSampleGroup) MaxMsgRate

func (sg *BenchSampleGroup) MaxMsgRate() int64

MaxMsgRate returns the largest message Rate in the SampleGroup

func (*BenchSampleGroup) MinLatency

func (sg *BenchSampleGroup) MinLatency() uint64

MinLatency returns the smallest average latency in microseconds in the SampleGroup

func (*BenchSampleGroup) MinMsgRate

func (sg *BenchSampleGroup) MinMsgRate() int64

MinMsgRate returns the smallest message Rate in the SampleGroup

func (*BenchSampleGroup) MsgRateStatistics

func (sg *BenchSampleGroup) MsgRateStatistics() string

MsgRateStatistics prints statistics for the message rates of the BenchSample group (min, average, max and standard deviation)

func (*BenchSampleGroup) StdDevMsgs added in v0.3.1

func (sg *BenchSampleGroup) StdDevMsgs() float64

StdDevMsgs returns the standard deviation the message rates in the SampleGroup

type BenchmarkResults

type BenchmarkResults struct {
	BenchSample
	Name           string
	RunID          string
	BenchType      string
	SampleGroup    *BenchSampleGroup
	SamplesChannel chan *BenchSample
}

BenchmarkResults to hold the various Samples organized by publishers and subscribers

func NewBenchmark

func NewBenchmark(name string, benchType string, clientCount int) *BenchmarkResults

NewBenchmark initializes a Benchmark. After creating a bench call AddSample. When done collecting samples, call Close() to calculate aggregates.

func (*BenchmarkResults) AddSample

func (bm *BenchmarkResults) AddSample(s *BenchSample)

AddSample adds a BenchSample to the BenchmarkResults

func (*BenchmarkResults) CSV

func (bm *BenchmarkResults) CSV() string

CSV generates a csv report of all the samples collected

func (*BenchmarkResults) Close

func (bm *BenchmarkResults) Close()

Close organizes collected Samples and calculates aggregates. After Close(), no more samples can be added.

func (*BenchmarkResults) Prefix

func (bm *BenchmarkResults) Prefix() string

Prefix generates the "P" or "S" prefix for the BenchmarkResults type

func (*BenchmarkResults) Report

func (bm *BenchmarkResults) Report() string

Report returns a human-readable report of the samples taken in the Benchmark

Jump to

Keyboard shortcuts

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