define

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

benchmark.go defines items relevent to the execution of benchmarks and the parsing of their output

config.go provides items which help define the current runtime configuration.

export.go defines items relevant to the export of benchmark data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Benchmarkable

type Benchmarkable interface {
	// Setup runs tasks which need to be done prior to calling Run.
	// These tasks could involve verifying integrity of config files or
	// creating needed objects.
	Setup(*Config) error
	// Run actually runs the benchmark and sends the benchmark's result
	// data to the Exporter. Assume benchmark passes if error is nil.
	Run(Exporterable) error

	// Teardown does any finishing tasks after the benchmark has ran and
	// exported its results.
	Teardown(*Config) error
}

Benchmarkable defines methods gobench needs to run a benchmark.

type Config

type Config struct {
	Verbose                          bool
	Quiet                            bool
	RunID                            string
	PrintJson                        bool
	ElasticsearchURL                 string
	ElasticsearchIndex               string
	ElasticsearchSkipVerify          bool
	ElasticsearchInjectProductHeader bool
}

Config defines common runtime objects which need to be accessed by other objects within gobench. It uses a singleton pattern. Reference: https://refactoring.guru/design-patterns/singleton/go/example

func GetConfig

func GetConfig() *Config

Get returns the current Config instance.

type Exporterable

type Exporterable interface {
	// Setup takes current Config and gets the Exporter ready to export data.
	// As an example, this could create a goroutine and some channels to
	// perform async export in the background.
	Setup(*Config) error
	// Teardown closes the Exporter down.
	Teardown() error
	// Healthcheck ensures that the exporter is ready to function.
	Healthcheck() error
	// Marshal prepares the given object to be exported by marshaling it into
	// a byte string.
	Marshal(interface{}) ([]byte, error)
	// Export takes the given byte string (assumed to be marshaled) and exports
	// it. Differenc exporters can choose whether to make this async or sync.
	Export([]byte) error
}

Exporterable defines methods needed by concrete Exporter objects. It is assumed that Exporterable objects are created with the intention of being added into the current runtime's Config.

type Metadata

type Metadata struct {
	RunID     string
	Timestamp int64
}

Metadata is a struct intended to be used by benchmarks to apply common metadata options to their payloads.

func GetMetadataPayload

func GetMetadataPayload(cfg *Config) Metadata

GetMetadataPayload constructs a new Metadata struct from the given Config instance.

Jump to

Keyboard shortcuts

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