math/bits: fix benchmarks (make sure calls don't get optimized away)
Sum up function results and store them in an exported (global)
variable. This prevents the compiler from optimizing away the
otherwise side-effect free function calls.
We now have more realistic set of benchmark numbers...
Measured on 2.3 GHz Intel Core i7, running maxOS 10.12.3.
Note: These measurements are based on the same "old"
implementation as the prior measurements (commit
7d5c003).
benchmark old ns/op new ns/op delta
BenchmarkReverse-8 72.9 8.50 -88.34%
BenchmarkReverse8-8 13.2 2.17 -83.56%
BenchmarkReverse16-8 21.2 2.89 -86.37%
BenchmarkReverse32-8 36.3 3.55 -90.22%
BenchmarkReverse64-8 71.3 6.81 -90.45%
BenchmarkReverseBytes-8 11.2 3.49 -68.84%
BenchmarkReverseBytes16-8 6.24 0.93 -85.10%
BenchmarkReverseBytes32-8 7.40 1.55 -79.05%
BenchmarkReverseBytes64-8 10.5 2.47 -76.48%
Reverse-8 72.9ns ± 0% 8.5ns ± 0% ~ (p=1.000 n=1+1)
Reverse8-8 13.2ns ± 0% 2.2ns ± 0% ~ (p=1.000 n=1+1)
Reverse16-8 21.2ns ± 0% 2.9ns ± 0% ~ (p=1.000 n=1+1)
Reverse32-8 36.3ns ± 0% 3.5ns ± 0% ~ (p=1.000 n=1+1)
Reverse64-8 71.3ns ± 0% 6.8ns ± 0% ~ (p=1.000 n=1+1)
ReverseBytes-8 11.2ns ± 0% 3.5ns ± 0% ~ (p=1.000 n=1+1)
ReverseBytes16-8 6.24ns ± 0% 0.93ns ± 0% ~ (p=1.000 n=1+1)
ReverseBytes32-8 7.40ns ± 0% 1.55ns ± 0% ~ (p=1.000 n=1+1)
ReverseBytes64-8 10.5ns ± 0% 2.5ns ± 0% ~ (p=1.000 n=1+1)
Change-Id: I8aef1334b84f6cafd25edccad7e6868b37969efb
Reviewed-on: https://go-review.googlesource.com/37213
Reviewed-by: Matthew Dempsky <mdempsky@google.com>