bench

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HumanBytes

func HumanBytes(bytes float64, si bool) string

HumanBytes formats bytes as a human readable string

func MsgsPerClient

func MsgsPerClient(numMsgs, numClients int) []int

MsgsPerClient divides the number of messages by the number of clients and tries to distribute them as evenly as possible

Types

type Benchmark

type Benchmark struct {
	Sample
	Name  string
	RunID string
	Pubs  *SampleGroup
	Subs  *SampleGroup
	// contains filtered or unexported fields
}

Benchmark to hold the various Samples organized by publishers and subscribers

func NewBenchmark

func NewBenchmark(name string, subCnt, pubCnt int) *Benchmark

NewBenchmark initializes a Benchmark. After creating a bench call AddSubSample/AddPubSample. When done collecting samples, call EndBenchmark

func (*Benchmark) AddPubSample

func (bm *Benchmark) AddPubSample(s *Sample)

AddPubSample to the benchmark

func (*Benchmark) AddSubSample

func (bm *Benchmark) AddSubSample(s *Sample)

AddSubSample to the benchmark

func (*Benchmark) CSV

func (bm *Benchmark) CSV() string

CSV generates a csv report of all the samples collected

func (*Benchmark) Close

func (bm *Benchmark) Close()

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

func (*Benchmark) Report

func (bm *Benchmark) Report() string

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

type Sample

type Sample struct {
	JobMsgCnt int
	MsgCnt    uint64
	MsgBytes  uint64
	IOBytes   uint64
	Start     time.Time
	End       time.Time
}

A Sample for a particular client

func NewSample

func NewSample(jobCount int, msgSize int, start, end time.Time, nc *nats.Conn) *Sample

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

func (*Sample) Duration

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

Duration that the sample was active

func (*Sample) Rate

func (s *Sample) Rate() int64

Rate of meessages in the job per second

func (*Sample) Seconds

func (s *Sample) Seconds() float64

Seconds that the sample or samples were active

func (*Sample) String

func (s *Sample) String() string

func (*Sample) Throughput

func (s *Sample) Throughput() float64

Throughput of bytes per second

type SampleGroup

type SampleGroup struct {
	Sample
	Samples []*Sample
}

SampleGroup for a number of samples, the group is a Sample itself agregating the values the Samples

func NewSampleGroup

func NewSampleGroup() *SampleGroup

NewSampleGroup initializer

func (*SampleGroup) AddSample

func (sg *SampleGroup) AddSample(e *Sample)

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

func (*SampleGroup) AvgRate

func (sg *SampleGroup) AvgRate() int64

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

func (*SampleGroup) HasSamples

func (sg *SampleGroup) HasSamples() bool

HasSamples returns true if the group has samples

func (*SampleGroup) MaxRate

func (sg *SampleGroup) MaxRate() int64

MaxRate returns the largest message rate in the SampleGroup

func (*SampleGroup) MinRate

func (sg *SampleGroup) MinRate() int64

MinRate returns the smallest message rate in the SampleGroup

func (*SampleGroup) Statistics

func (sg *SampleGroup) Statistics() string

Statistics information of the sample group (min, average, max and standard deviation)

func (*SampleGroup) StdDev

func (sg *SampleGroup) StdDev() float64

StdDev returns the standard deviation the message rates in the SampleGroup

Jump to

Keyboard shortcuts

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