tools

package
v0.0.0-...-d118c2b Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: Apache-2.0, MIT Imports: 7 Imported by: 5

Documentation

Overview

Package tools holds tooling to couple command formatting and output parsers together.

Index

Constants

View Source
const (
	EngineSync   = IOEngine("sync")
	EngineLibAIO = IOEngine("libaio")
)

Names of FIO I/O engines.

Variables

This section is empty.

Functions

func ExtractRubyLoadTime

func ExtractRubyLoadTime(output string) (time.Duration, error)

ExtractRubyLoadTime extracts the load time from fastlane ruby test output.

func ExtractRubyTestTime

func ExtractRubyTestTime(output string) (time.Duration, error)

ExtractRubyTestTime extracts the test time from fastlane ruby test output.

func ParametersToName

func ParametersToName(params ...Parameter) (string, error)

ParametersToName joins parameters into a string format for parsing. It is meant to be used for t.Run() calls in benchmark tools.

func ReportCustomMetric

func ReportCustomMetric(b *testing.B, value float64, name, unit string)

ReportCustomMetric reports a metric in a set format for parsing.

Types

type ApacheBench

type ApacheBench struct {
	Requests    int
	Concurrency int
	Doc         string
}

ApacheBench is for the client application ApacheBench.

func (*ApacheBench) MakeCmd

func (a *ApacheBench) MakeCmd(host string, port int) []string

MakeCmd makes an ApacheBench command.

func (*ApacheBench) Report

func (a *ApacheBench) Report(b *testing.B, output string)

Report parses and reports metrics from ApacheBench output.

type Fio

type Fio struct {
	Test        string   // test to run: read, write, randread, randwrite.
	IOEngine    IOEngine // ioengine to use: sync or libaio.
	SizeMB      int      // total size to be read/written in megabytes.
	BlockSizeKB int      // block size to be read/written in kilobytes.
	IODepth     int      // I/O depth for reads/writes when using libaio.
	Jobs        int      // Number of jobs running in concurrent threads.
	Direct      bool     // Whether to use direct I/O (O_DIRECT) or not.
}

Fio makes 'fio' commands and parses their output.

func (*Fio) MakeCmd

func (f *Fio) MakeCmd(filename string) []string

MakeCmd makes a 'fio' command.

func (*Fio) Parameters

func (f *Fio) Parameters(b *testing.B, additional ...Parameter) ([]Parameter, string)

Parameters returns the test parameters and the overall test name derived from them.

func (*Fio) Report

func (f *Fio) Report(b *testing.B, output string)

Report reports metrics based on output from an 'fio' command.

type Hackbench

type Hackbench struct {
	IpcMode     string // ipc mode: pipe, socket(default)
	ProcessMode string // process mode: thread, process(default)
}

Hackbench makes 'hackbench' commands and parses their output.

func (*Hackbench) MakeCmd

func (s *Hackbench) MakeCmd(b *testing.B) []string

MakeCmd makes commands for Hackbench.

func (*Hackbench) Report

func (s *Hackbench) Report(b *testing.B, output string)

Report reports the relevant metrics for Hackbench.

type Hey

type Hey struct {
	Requests    int // Note: requests cannot be less than concurrency.
	Concurrency int
	Doc         string
}

Hey is for the client application 'hey'.

func (*Hey) MakeCmd

func (h *Hey) MakeCmd(host string, port int) []string

MakeCmd returns a 'hey' command.

func (*Hey) Report

func (h *Hey) Report(b *testing.B, output string)

Report parses output from 'hey' and reports metrics.

type IOEngine

type IOEngine string

IOEngine is a I/O engine name passed to `fio`.

type Iperf

type Iperf struct {
	Num      int // Number of bytes to send in KB.
	Parallel int // Number of parallel threads.
}

Iperf is for the client side of `iperf`.

func (*Iperf) MakeCmd

func (i *Iperf) MakeCmd(host string, port int) []string

MakeCmd returns a iperf client command.

func (*Iperf) Report

func (i *Iperf) Report(b *testing.B, output string)

Report parses output from iperf client and reports metrics.

type Meminfo

type Meminfo struct {
}

Meminfo wraps measurements of MemAvailable using /proc/meminfo.

func (*Meminfo) MakeCmd

func (*Meminfo) MakeCmd() (string, []string)

MakeCmd returns a command for checking meminfo.

func (*Meminfo) Report

func (*Meminfo) Report(b *testing.B, before, after string)

Report takes two reads of meminfo, parses them, and reports the difference divided by b.N.

type Metric

type Metric struct {
	Name   string
	Unit   string
	Sample float64
}

Metric holds metric data parsed from a string based on the format ReportMetric.

func ParseCustomMetric

func ParseCustomMetric(value, metric string) (*Metric, error)

ParseCustomMetric parses a metric reported with ReportCustomMetric.

type Parameter

type Parameter struct {
	Name  string
	Value string
}

Parameter is a test parameter.

func NameToParameters

func NameToParameters(name string) ([]*Parameter, error)

NameToParameters parses the string created by ParametersToName and returns it as a set of Parameters. Example: BenchmarkRuby/server_threads.1/doc_size.16KB-6 The parameter part of this benchmark is: "server_threads.1/doc_size.16KB" (BenchmarkRuby is the name, and 6 is GOMAXPROCS) This function will return a slice with two parameters -> {Name: server_threads, Value: 1}, {Name: doc_size, Value: 16KB}

type Redis

type Redis struct {
	Operation string
}

Redis is for the client 'redis-benchmark'.

func (*Redis) MakeCmd

func (r *Redis) MakeCmd(host string, port, requests int) []string

MakeCmd returns a redis-benchmark client command.

func (*Redis) Report

func (r *Redis) Report(b *testing.B, output string)

Report parses output from redis-benchmark client and reports metrics.

type Sysbench

type Sysbench interface {
	// MakeCmd constructs the relevant command line.
	MakeCmd(*testing.B) []string

	// Report reports relevant custom metrics.
	Report(*testing.B, string)
}

Sysbench represents a 'sysbench' command.

type SysbenchBase

type SysbenchBase struct {
	// Threads is the number of threads for the test.
	Threads int
}

SysbenchBase is the top level struct for sysbench and holds top-level arguments for sysbench. See: 'sysbench --help'

type SysbenchCPU

type SysbenchCPU struct {
	SysbenchBase
}

SysbenchCPU is for 'sysbench [flags] cpu run' and holds CPU specific arguments.

func (*SysbenchCPU) MakeCmd

func (s *SysbenchCPU) MakeCmd(b *testing.B) []string

MakeCmd makes commands for SysbenchCPU.

func (*SysbenchCPU) Report

func (s *SysbenchCPU) Report(b *testing.B, output string)

Report reports the relevant metrics for SysbenchCPU.

type SysbenchMemory

type SysbenchMemory struct {
	SysbenchBase
	BlockSize     int    // size of test memory block in megabytes [1].
	Scope         string // memory access scope {global, local} [global].
	HugeTLB       bool   // allocate memory from HugeTLB [off].
	OperationType string // type of memory ops {read, write, none} [write].
	AccessMode    string // access mode {seq, rnd} [seq].
}

SysbenchMemory is for 'sysbench [FLAGS] memory run' and holds Memory specific arguments.

func (*SysbenchMemory) MakeCmd

func (s *SysbenchMemory) MakeCmd(b *testing.B) []string

MakeCmd makes commands for SysbenchMemory.

func (*SysbenchMemory) Report

func (s *SysbenchMemory) Report(b *testing.B, output string)

Report reports the relevant metrics for SysbenchMemory.

type SysbenchMutex

type SysbenchMutex struct {
	SysbenchBase
	Num   int // total size of mutex array [4096].
	Loops int // number of loops to do outside mutex lock [10000].
}

SysbenchMutex is for 'sysbench [FLAGS] mutex run' and holds Mutex specific arguments.

func (*SysbenchMutex) MakeCmd

func (s *SysbenchMutex) MakeCmd(b *testing.B) []string

MakeCmd makes commands for SysbenchMutex.

func (*SysbenchMutex) Report

func (s *SysbenchMutex) Report(b *testing.B, output string)

Report parses and reports relevant sysbench mutex metrics.

Jump to

Keyboard shortcuts

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