]> Cypherpunks repositories - gostls13.git/commit
testing: fix fractional ns/op printing
authorAustin Clements <austin@google.com>
Fri, 22 Mar 2019 18:18:22 +0000 (14:18 -0400)
committerAustin Clements <austin@google.com>
Fri, 22 Mar 2019 21:19:22 +0000 (21:19 +0000)
commit1257d05088c3842efa2aa23f8d6abe000e494f1a
tree0504e8cfe0746431e74767ec5e9b8f2c509f116f
parent94563de87fad642677ffc62a4a82766597e39123
testing: fix fractional ns/op printing

CL 166717 changed the way ns/op benchmark results were printed and
inadvertently rounded all ns/op results down to an integer, even if
they were small enough to print with digits after the decimal place.
For example, prior to this change, we got output like

    BenchmarkFast-8       380491575  3.12 ns/op

CL 166717 changed this to

    BenchmarkFast-8       380491575      3.00 ns/op

This had the further side-effect that ns/op values between 0 and 1
would not be printed at all because they would be rounded down to 0.

This CL fixes this by always recomputing the float64 value of ns/op
instead of using the int64 truncation from BenchmarkResult.NsPerOp.

Fixes #30997. Fixes #31005.

Change-Id: I21f73b9d5cc5ad41e7ff535675d07ca00051ecd7
Reviewed-on: https://go-review.googlesource.com/c/go/+/168937
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
src/testing/benchmark.go
src/testing/benchmark_test.go