benchmarkconn

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: BSD-3-Clause Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Benchmark

type Benchmark interface {
	Writer(net.Conn, ...Counter) error
	Reader(net.Conn, ...Counter) error
	Result() map[string]any
}

type CombinedCounter

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

func CombineCounters

func CombineCounters(interval time.Duration, counters ...Counter) *CombinedCounter

func (*CombinedCounter) CountAllNow

func (c *CombinedCounter) CountAllNow()

func (*CombinedCounter) Results

func (c *CombinedCounter) Results() []map[time.Time]any

func (*CombinedCounter) Start

func (c *CombinedCounter) Start()

func (*CombinedCounter) Stop

func (c *CombinedCounter) Stop()

type Counter

type Counter interface {
	CountNow() // CountNow forcibly make the counter take a measurement immediately and save it to the result

	Start()
	Stop()
	Result() map[time.Time]any // Result values must be printable and/or JSON-serializable
}

func NewCpuUsageCounter

func NewCpuUsageCounter(interval time.Duration) Counter

func NewMemoryUsageCounter

func NewMemoryUsageCounter(interval time.Duration) Counter

type CounterBase

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

CounterBase is an incomplete implementation of Counter.

func NewCounterBase

func NewCounterBase(interval time.Duration) *CounterBase

NewCounterBase creates a new CounterBase and initializes its internal fields.

func (*CounterBase) Result

func (c *CounterBase) Result() map[time.Time]any

Result returns the result of the counter.

It is recommended for Counter implementations to directly inherit this method.

func (*CounterBase) Start

func (c *CounterBase) Start()

Start starts the ticker only. Implementation of Counter must listen for the ticker and the closed channel.

func (*CounterBase) Stop

func (c *CounterBase) Stop()

Stop stops the ticker and closes the closed channel.

It is recommended for Counter implementations to directly inherit this method.

type CounterReport

type CounterReport interface {
	Add(time time.Time, value any)
	Result() map[time.Time]any
}

func NewCounterReport

func NewCounterReport() CounterReport

type IntervalBenchmark

type IntervalBenchmark struct {
	MessageSize   int           `json:"message_size" yaml:"message_size"`     // MessageSize defines how many bytes to write for each send attempt
	TotalMessages uint64        `json:"total_messages" yaml:"total_messages"` // TotalMessages defines how many messages to send in total
	Interval      time.Duration `json:"interval" yaml:"interval"`             // Interval defines how long to wait between each send attempt. If this value is too low, it is possible that the actual interval will be much higher due to system limitations
	Echo          bool          `json:"echo" yaml:"echo"`                     // Echo defines whether the receiver should echo back the received message
	// contains filtered or unexported fields
}

IntervalBenchmark is a benchmark that sends a fixed number of messages of a fixed size one after another with a fixed interval between each send attempt and measures the throughput and latency.

func (*IntervalBenchmark) Reader

func (b *IntervalBenchmark) Reader(conn net.Conn, counters ...Counter) error

func (*IntervalBenchmark) Result

func (b *IntervalBenchmark) Result() map[string]any

func (*IntervalBenchmark) Writer

func (b *IntervalBenchmark) Writer(conn net.Conn, counters ...Counter) error

type PressuredBenchmark

type PressuredBenchmark struct {
	MessageSize   int    `json:"message_size" yaml:"message_size"`     // MessageSize defines how many bytes to write for each send attempt
	TotalMessages uint64 `json:"total_messages" yaml:"total_messages"` // TotalMessages defines how many messages to send in total
	// contains filtered or unexported fields
}

PressuredBenchmark is a benchmark that sends a fixed number of messages of a fixed size one after another as fast as possible and measures the throughput and latency.

func (*PressuredBenchmark) Reader

func (b *PressuredBenchmark) Reader(conn net.Conn, counters ...Counter) error

func (*PressuredBenchmark) Result

func (b *PressuredBenchmark) Result() map[string]any

func (*PressuredBenchmark) Writer

func (b *PressuredBenchmark) Writer(conn net.Conn, counters ...Counter) error

Directories

Path Synopsis
cmd
client command
server command

Jump to

Keyboard shortcuts

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