benchmark

package
v0.0.0-...-2e52d37 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultBConfig

func DefaultBConfig() config.Bconfig

DefaultBConfig returns a default benchmark config

Types

type Benchmark

type Benchmark struct {
	config.Bconfig
	*History
	// contains filtered or unexported fields
}

Benchmark is benchmarking tool that generates workload and collects operation history and latency

func NewBenchmark

func NewBenchmark(db DB) *Benchmark

NewBenchmark returns new Benchmark object given implementation of DB interface

func (*Benchmark) Run

func (b *Benchmark) Run()

Run starts the main logic of benchmarking

type DB

type DB interface {
	Init() error
	Write(key int, value []byte) error
	Stop() error
}

DB is general interface implemented by client to call client library

type History

type History struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

History client operation history mapped by key

func NewHistory

func NewHistory() *History

NewHistory creates a History map

func (*History) Add

func (h *History) Add(key int, input, output interface{}, start, end int64)

Add puts an operation in History

func (*History) AddOperation

func (h *History) AddOperation(key int, o *operation)

AddOperation adds the operation

func (*History) ReadFile

func (h *History) ReadFile(path string) error

ReadFile reads csv log file and create operations in history

func (*History) WriteFile

func (h *History) WriteFile(path string) error

WriteFile writes entire operation history into file

type Limiter

type Limiter struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Limiter limits operation rate when used with Wait function

func NewLimiter

func NewLimiter(rate int) *Limiter

NewLimiter creates a new rate limiter, where rate is operations per second

func (*Limiter) Wait

func (l *Limiter) Wait()

Wait blocks for the limit

type Stat

type Stat struct {
	Data   []float64
	Size   int
	Mean   float64
	Min    float64
	Max    float64
	Median float64
	P95    float64
	P99    float64
	P999   float64
}

Stat stores the statistics data for benchmarking results

func Statistic

func Statistic(latency []time.Duration) Stat

Statistic function creates Stat object from raw latency data

func (Stat) String

func (s Stat) String() string

func (Stat) WriteFile

func (s Stat) WriteFile(path string) error

WriteFile writes stat to new file in path

Jump to

Keyboard shortcuts

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