Documentation
¶
Overview ¶
Package benchmark provides the representation of a single benchmark consisting of a function and its converted types.
Package benchmark helper methods
Index ¶
- Constants
- func GetFunctionName(i interface{}) string
- type Benchmark
- func (benchmark *Benchmark) GetConvertedType(t ConversionType) time.Duration
- func (benchmark Benchmark) GetDesc() string
- func (benchmark Benchmark) GetElapsedTime() time.Duration
- func (benchmark Benchmark) GetFunction() func()
- func (benchmark Benchmark) GetIterations() int
- func (benchmark *Benchmark) GetStates() map[string]time.Duration
- func (benchmark Benchmark) GetUnits() []ConversionType
- func (benchmark Benchmark) Main()
- func (benchmark *Benchmark) Start()
- func (benchmark *Benchmark) TimeElapsed(units []ConversionType)
- type ConversionType
Constants ¶
const ( // Milli Milliseconds Milli ConversionType = "ms" // Micro Microseconds Micro = "us" // Nano Nanoseconds Nano = "ns" // Sec Seconds Sec = "s" // Min Minutes Min = "m" // Hr Hours Hr = "hr" )
Variables ¶
This section is empty.
Functions ¶
func GetFunctionName ¶
func GetFunctionName(i interface{}) string
GetFunctionName get the running function name of a objectBenchmark. ref: https://stackoverflow.com/a/7053871
Types ¶
type Benchmark ¶
type Benchmark struct {
// contains filtered or unexported fields
}
Benchmark Represents a single instance of a benchmark.
func NewBenchmark ¶
func NewBenchmark(description string, function func(), iterations int, units ...ConversionType) Benchmark
NewBenchmark create a new Benchmark Object.
func (*Benchmark) GetConvertedType ¶
func (benchmark *Benchmark) GetConvertedType(t ConversionType) time.Duration
GetConvertedType get ConvertedType according to t (ConversionType).
func (Benchmark) GetElapsedTime ¶
GetElapsedTime get the the elapsed time.
func (Benchmark) GetFunction ¶
func (benchmark Benchmark) GetFunction() func()
GetFunction get the measuring function.
func (Benchmark) GetIterations ¶
GetIterations get the number of iterations.
func (*Benchmark) GetStates ¶
GetStates get time.Duration at each time in a key value pair of iterations and durations.
func (Benchmark) GetUnits ¶
func (benchmark Benchmark) GetUnits() []ConversionType
GetUnits get the units that the user wants during execution.
func (*Benchmark) Start ¶
func (benchmark *Benchmark) Start()
Start starts the timer for measuring the function.
func (*Benchmark) TimeElapsed ¶
func (benchmark *Benchmark) TimeElapsed(units []ConversionType)
TimeElapsed calculates time elapsed and performs conversion of units.
type ConversionType ¶
type ConversionType string
ConversionType represents a unit that can be converted.