Commit 03a79e9
committed
testing: stop rounding b.N
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 <[email protected]>1 parent 3023d7d commit 03a79e9
File tree
4 files changed
+24
-108
lines changed- src
- cmd/go
- testing
4 files changed
+24
-108
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4947 | 4947 | | |
4948 | 4948 | | |
4949 | 4949 | | |
4950 | | - | |
| 4950 | + | |
4951 | 4951 | | |
4952 | 4952 | | |
4953 | 4953 | | |
4954 | 4954 | | |
4955 | 4955 | | |
4956 | 4956 | | |
4957 | | - | |
| 4957 | + | |
4958 | 4958 | | |
4959 | 4959 | | |
4960 | 4960 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | 173 | | |
181 | 174 | | |
182 | 175 | | |
| |||
199 | 192 | | |
200 | 193 | | |
201 | 194 | | |
202 | | - | |
| 195 | + | |
203 | 196 | | |
204 | 197 | | |
205 | 198 | | |
206 | 199 | | |
207 | 200 | | |
208 | 201 | | |
209 | | - | |
| 202 | + | |
210 | 203 | | |
211 | 204 | | |
212 | 205 | | |
213 | 206 | | |
214 | 207 | | |
215 | 208 | | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | 209 | | |
250 | 210 | | |
251 | 211 | | |
| |||
328 | 288 | | |
329 | 289 | | |
330 | 290 | | |
331 | | - | |
| 291 | + | |
332 | 292 | | |
333 | 293 | | |
334 | | - | |
335 | | - | |
336 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
337 | 300 | | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
338 | 307 | | |
| 308 | + | |
339 | 309 | | |
| 310 | + | |
340 | 311 | | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
345 | 316 | | |
346 | 317 | | |
347 | 318 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | 17 | | |
69 | 18 | | |
70 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
| 7 | + | |
0 commit comments