api

package
v0.0.0-...-172d9b4 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package api implements the common interface exposed by all benchmarks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Benchmarks

func Benchmarks() map[string]Benchmark

Benchmarks returns a map of all registered benchmarks.

func RegisterBenchmark

func RegisterBenchmark(bench Benchmark)

RegisterBenchmark registers a new benchmark.

Types

type Benchmark

type Benchmark interface {
	Name() string
	Scenario(context.Context, *State) (uint64, error)
}

Benchmark is the interface exposed by each benchmark.

type BulkCleanupable

type BulkCleanupable interface {
	BulkCleanup(context.Context, []*State)
}

BulkCleanupable is the interface exposed by benchmarks that require a bulk cleanup step.

If a benchmark is also a Cleanupable, the BulkCleanup operation will be invoked before any Prepare operations are dispatched.

type BulkPreparable

type BulkPreparable interface {
	BulkPrepare(context.Context, []*State) error
}

BulkPreparable is the interface exposed by benchmarks that require a bulk pre-flight prepare step.

If a benchmark also is a Preparable, the BulkPrepare operation will be invoked after every Prepeare operation has been completed.

type Cleanupable

type Cleanupable interface {
	Cleanup(*State)
}

Cleanupable is the interface exposed by benchmarks require a post-flight cleanup step.

type Config

type Config struct {
	Logger log.Logger
	URL    *url.URL

	Concurrency     int
	Duration        time.Duration
	Rate            uint
	LogVerboseDebug bool
}

Config is a benchmark run configuration.

func (*Config) RunBenchmark

func (cfg *Config) RunBenchmark(ctx context.Context, benchmark Benchmark) error

RunBenchmark runs the benchmark with the provided configuration.

type Prepareable

type Prepareable interface {
	Prepare(context.Context, *State) error
}

Prepareable is the interface exposed by benchmarks requiring a pre-flight prepare step.

type State

type State struct {
	Id        uint64
	Config    *Config
	Logger    log.Logger
	RPCClient *rpc.Client

	State interface{}
}

State is the per-goroutine benchmark state.

type SuiteInitFn

type SuiteInitFn func(*cobra.Command)

SuiteInitFn is the initializer exposed by each benchmark suite package.

Jump to

Keyboard shortcuts

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