testing: only find the target b.N once when -count > 1 #23423
Labels
Milestone
Comments
Change https://golang.org/cl/110775 mentions this issue: |
Moderately ugly fix I'm not 100% sure about in the change gopherbot linked above. |
Re-opening this since the change linked above was reverted. See #25622 for a description of the issues it was causing. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
go test
runs benchmarks with increasing b.N values to find a large enough value depending onbenchtime
. If you run with-count
> 1, it will do that every time rather than just once.For instance, with this code:
if I run
I get
In this case, if
go test
had remembered the target value (1000) the first time, it would've avoided two adjustment runs the second time around and would have saved about 1s. The effect is larger when-count
is higher, as is typical for people gathering multiple runs for use with benchstat.(Side note: it would've been nice if
go test
had picked a smaller value than 1000 here. It took 10s when I asked for 5s.)It's possible that the fix for #19128 (
-benchsplit
) will also incidentally fix this. I haven't studied the CL yet./cc @rsc @josharian @bcmills
The text was updated successfully, but these errors were encountered: