Skip to content

Commit

Permalink
make stopwatch implement hrplot.Benchmark interface
Browse files Browse the repository at this point in the history
  • Loading branch information
egonelbre committed Apr 2, 2019
1 parent 05c070a commit fa0c7d5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions stopwatch.go
Expand Up @@ -110,6 +110,21 @@ func (bench *Stopwatch) Durations() []time.Duration {
return durations
}

// Name returns name of the benchmark.
func (bench *Stopwatch) Name() string { return "" }

// Unit returns units it measures.
func (bench *Stopwatch) Unit() string { return "ns" }

// Float64s returns all measurements.
func (bench *Stopwatch) Float64s() []float64 {
measurements := make([]float64, len(bench.spans))
for i := range measurements {
measurements[i] = float64(bench.spans[i].Duration().Nanoseconds())
}
return measurements
}

// Histogram creates an histogram of all the durations.
//
// It creates binCount bins to distribute the data and uses the
Expand Down
15 changes: 15 additions & 0 deletions stopwatchtsc.go
Expand Up @@ -111,6 +111,21 @@ func (bench *StopwatchTSC) ApproxDurations() []time.Duration {
return durations
}

// Name returns name of the benchmark.
func (bench *StopwatchTSC) Name() string { return "" }

// Unit returns units it measures.
func (bench *StopwatchTSC) Unit() string { return "tsc" }

// Float64s returns all measurements.
func (bench *StopwatchTSC) Float64s() []float64 {
measurements := make([]float64, len(bench.spans))
for i := range measurements {
measurements[i] = float64(bench.spans[i].Count())
}
return measurements
}

// Histogram creates an histogram of all the durations.
//
// It creates binCount bins to distribute the data and uses the
Expand Down

0 comments on commit fa0c7d5

Please sign in to comment.