summaryrefslogtreecommitdiff
path: root/src/testing/benchmark_test.go
Commit message (Collapse)AuthorAgeFilesLines
* testing: shorten go test -short testingRuss Cox2019-05-161-0/+3
| | | | | | | | | | This cuts the time for 'go test -short testing' from 0.9s to < 0.1s. Change-Id: Ib8402f80239e1e96ea5221dfd5cd0db08170d85b Reviewed-on: https://go-review.googlesource.com/c/go/+/177420 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* testing: fix fractional ns/op printingAustin Clements2019-03-221-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* testing: stop rounding b.NJosh Bleecher Snyder2019-03-201-51/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The original goal of rounding to readable b.N was to make it easier to eyeball times. However, proper analysis requires tooling (such as benchstat) anyway. Instead, take b.N as it comes. This will reduce the impact of external noise such as GC on benchmarks. This requires reworking our iteration estimates. We used to calculate the estimated ns/op and then divide our target ns by that estimate. However, this order of operations was destructive when the ns/op was very small; rounding could hide almost an order of magnitude of variation. Instead, multiply first, then divide. Also, make n an int64 to avoid overflow. Prior to this change, we attempted to cap b.N at 1e9. Due to rounding up, it was possible to get b.N as high as 2e9. This change consistently enforces the 1e9 cap. This change also reduces the wall time required to run benchmarks. Here's the impact of this change on the wall time to run all benchmarks once with benchtime=1s on some std packages: name old time/op new time/op delta bytes 306s ± 1% 238s ± 1% -22.24% (p=0.000 n=10+10) encoding/json 112s ± 8% 99s ± 7% -11.64% (p=0.000 n=10+10) net/http 54.7s ± 7% 44.9s ± 4% -17.94% (p=0.000 n=10+9) runtime 957s ± 1% 714s ± 0% -25.38% (p=0.000 n=10+9) strings 262s ± 1% 201s ± 1% -23.27% (p=0.000 n=10+10) [Geo mean] 216s 172s -20.23% Updates #24735 Change-Id: I7e38efb8e23c804046bf4fc065b3f5f3991d0a15 Reviewed-on: https://go-review.googlesource.com/c/go/+/112155 Reviewed-by: Austin Clements <austin@google.com>
* testing: add B.ReportMetric for custom benchmark metricsAustin Clements2019-03-191-0/+63
| | | | | | | | | | | | | | This adds a ReportMetric method to testing.B that lets the user report custom benchmark metrics and override built-in metrics. Fixes #26037. Change-Id: I8236fbde3683fc27bbe45cbbedfd377b435edf64 Reviewed-on: https://go-review.googlesource.com/c/go/+/166717 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
* build: move package sources from src/pkg to srcRuss Cox2014-09-081-0/+113
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.