aboutsummaryrefslogtreecommitdiff
path: root/src/pkg
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2014-06-12 07:51:32 -0700
committerJosh Bleecher Snyder <josharian@gmail.com>2014-06-12 07:51:32 -0700
commita5bb1af43214c3da52d1752e58d03ed968e6a11b (patch)
tree0f742c6679291b5bfb7e65b3762ae42298360adf /src/pkg
parent0476693eaf871653139735cc231c3c80f4daf7c9 (diff)
downloadgo-a5bb1af43214c3da52d1752e58d03ed968e6a11b.tar.xz
testing: make benchmarking faster
Allow the number of benchmark iterations to grow faster for fast benchmarks, and don't round up twice. Using the default benchtime, this CL reduces wall clock time to run benchmarks: net/http 49s -> 37s (-24%) runtime 8m31s -> 5m55s (-30%) bytes 2m37s -> 1m29s (-43%) encoding/json 29s -> 21s (-27%) strings 1m16s -> 53s (-30%) LGTM=crawshaw R=golang-codereviews, crawshaw CC=golang-codereviews https://golang.org/cl/101970047
Diffstat (limited to 'src/pkg')
-rw-r--r--src/pkg/testing/benchmark.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/pkg/testing/benchmark.go b/src/pkg/testing/benchmark.go
index 1fbf5c8615..43bbecbdc6 100644
--- a/src/pkg/testing/benchmark.go
+++ b/src/pkg/testing/benchmark.go
@@ -205,10 +205,12 @@ func (b *B) launch() {
} else {
n = int(d.Nanoseconds() / b.nsPerOp())
}
- // Run more iterations than we think we'll need for a second (1.5x).
- // Don't grow too fast in case we had timing errors previously.
+ // If the last run was small, don't grow too fast.
+ if last < 1000 {
+ n = min(n, 100*last)
+ }
// Be sure to run at least one more than last time.
- n = max(min(n+n/2, 100*last), last+1)
+ n = max(n, last+1)
// Round up to something easy to read.
n = roundUp(n)
b.runN(n)