diff options
Diffstat (limited to 'src/testing/benchmark_test.go')
| -rw-r--r-- | src/testing/benchmark_test.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/testing/benchmark_test.go b/src/testing/benchmark_test.go index 3b1dc8275b..7e456f9a40 100644 --- a/src/testing/benchmark_test.go +++ b/src/testing/benchmark_test.go @@ -176,5 +176,8 @@ func ExampleB_ReportMetric() { // This metric is per-operation, so divide by b.N and // report it as a "/op" unit. b.ReportMetric(float64(compares)/float64(b.N), "compares/op") + // This metric is per-time, so divide by b.Elapsed and + // report it as a "/ns" unit. + b.ReportMetric(float64(compares)/float64(b.Elapsed().Nanoseconds()), "compares/ns") }) } |
