compare_benchmark: fix ops/sec output. The proper formula for a µs benchmark is not: `time.Microsecond / cpuTimeUS` but: `time.Second / (cpuTimeUS * time.Microsecond)` which simplifies to: `(time.Second / time.Microsecond) / cpuTimeUS` Change-Id: Ibec07cd968e44ea296175a4028f97a2b6a6a6964 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/101227 Commit-Queue: Rudolf Polzer <rpolzer@google.com> Reviewed-by: Xiangfei Ding <xfding@google.com> Commit-Queue: Xiangfei Ding <xfding@google.com> Auto-Submit: Rudolf Polzer <rpolzer@google.com>
diff --git a/util/compare_benchmarks.go b/util/compare_benchmarks.go index 867b0ef..eed190c 100644 --- a/util/compare_benchmarks.go +++ b/util/compare_benchmarks.go
@@ -45,6 +45,7 @@ if r.BytesPerSecond != 0 { return r.BytesPerSecond / 1000000, "MB/sec" } + var unit time.Duration switch r.TimeUnit { case "ns": @@ -56,7 +57,7 @@ default: log.Panicf("unsupported time unit: %q", r.TimeUnit) } - return float64(unit) / r.CPUTime, "ops/sec" + return float64(time.Second/unit) / r.CPUTime, "ops/sec" } func printResult(result Result, baseline *Result) error {