Commit 31ad583a authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder Committed by Marcel van Lohuizen

testing: respect benchtime on very fast benchmarks

When ns/op dropped below 1, the old code
ignored benchtime and reverted to 1s.

Change-Id: I59752cef88d8d73bfd5b085f5400ae657f78504e
Reviewed-on: https://go-review.googlesource.com/26664
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: 's avatarMarcel van Lohuizen <mpvl@golang.org>
parent 392bf3a9
......@@ -263,10 +263,9 @@ func (b *B) launch() {
for n := 1; !b.failed && b.duration < d && n < 1e9; {
last := n
// Predict required iterations.
if b.nsPerOp() == 0 {
n = 1e9
} else {
n = int(d.Nanoseconds() / b.nsPerOp())
n = int(d.Nanoseconds())
if nsop := b.nsPerOp(); nsop != 0 {
n /= int(nsop)
}
// Run more iterations than we think we'll need (1.2x).
// Don't grow too fast in case we had timing errors previously.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment