benchmark

package
v0.0.0-...-683b059 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package benchmark provides utilities for running Google Benchmark binaries on device.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtraArgs

func ExtraArgs(args ...string) option

ExtraArgs sets a list of arguments that will be passed to the benchmark binary.

func Filter

func Filter(pattern string) option

Filter sets the benchmark name filter pattern.

func OutputFile

func OutputFile(file string) option

OutputFile sets the additional output file path.

func OutputResultFormat

func OutputResultFormat(format Format) option

OutputResultFormat sets the output formatting for the additional output file.

Types

type Benchmark

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

Benchmark encapsulates all the context for running a benchmark binary.

func New

func New(exec string, opts ...option) *Benchmark

New creates a Benchmark instance with the given options.

func (*Benchmark) Args

func (b *Benchmark) Args() []string

Args returns an array of string for benchmark execution.

func (*Benchmark) Run

func (b *Benchmark) Run(ctx context.Context) (*Result, error)

Run executes the benchmark and returns the benchmark result in a byte array.

type Context

type Context struct {
	Date              string `json:"date"`
	HostName          string `json:"host_name"`
	Executable        string `json:"executable"`
	NumCPUs           int    `json:"num_cpus"`
	MhzPerCPU         int    `json:"mhz_per_cpu"`
	CPUScalingEnabled bool   `json:"cpu_scaling_enabled"`
	Cached            []struct {
		Type       string `json:"type"`
		Level      int    `json:"level"`
		Size       int    `json:"size"`
		NumSharing int    `json:"num_sharing"`
	} `json:"caches"`
	LoadAvg          []float32 `json:"load_avg"`
	LibraryBuildType string    `json:"library_build_type"`
}

Context is a struct representing the device context as probed by the benchmark binary.

type Format

type Format int

Format defines the output formatting of the benchmark run.

const (
	// Console sets the output formatting to human-readable texts. This is
	// the default used by Google Benchmark.
	Console Format = iota

	// JSON sets the output formatting to JSON.
	JSON

	// CSV sets the output format to CSV.
	CSV
)

type Output

type Output struct {
	Name                   string  `json:"name"`
	FamilyIndex            int     `json:"family_index"`
	PerFamilyInstanceIndex int     `json:"per_family_instance_index"`
	RunName                string  `json:"run_name"`
	RunType                string  `json:"run_type"`
	Repetitions            int     `json:"repetitions"`
	RepetitionIndex        int     `json:"repetition_index"`
	Threads                int     `json:"threads"`
	Iterations             int     `json:"iterations"`
	RealTime               float64 `json:"real_time"`
	CPUTime                float64 `json:"cpu_time"`
	TimeUnit               string  `json:"time_unit"`
}

Output is a struct representing one benchmark execution output.

type Result

type Result struct {
	Context    Context  `json:"context"`
	Benchmarks []Output `json:"benchmarks"`
}

Result is a struct representing the complete result of one benchmark run.

Jump to

Keyboard shortcuts

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