diff options
| author | Junyang Shao <shaojunyang@google.com> | 2025-03-18 21:13:23 +0000 |
|---|---|---|
| committer | Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2025-03-20 12:42:51 -0700 |
| commit | b613d21ffd17c1dda480b205f0cce5031bdbd5dd (patch) | |
| tree | c0cb496cc552291bb36f296cc857e253440eb90a /src/testing/loop_test.go | |
| parent | ba50de84299667dcaa2f4e6663078340bbae8c67 (diff) | |
| download | go-b613d21ffd17c1dda480b205f0cce5031bdbd5dd.tar.xz | |
testing: allow manual timer control in testing.B.Loop
Fixes #72922
Change-Id: I56610d2d11d151a8f95b6434bbedbfcd5c11c317
Reviewed-on: https://go-review.googlesource.com/c/go/+/658975
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/testing/loop_test.go')
| -rw-r--r-- | src/testing/loop_test.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/testing/loop_test.go b/src/testing/loop_test.go index 7a1a93fcee..781a8566e8 100644 --- a/src/testing/loop_test.go +++ b/src/testing/loop_test.go @@ -7,7 +7,7 @@ package testing func TestBenchmarkBLoop(t *T) { var initialStart highPrecisionTime var firstStart highPrecisionTime - var lastStart highPrecisionTime + var scaledStart highPrecisionTime var runningEnd bool runs := 0 iters := 0 @@ -19,7 +19,9 @@ func TestBenchmarkBLoop(t *T) { if iters == 0 { firstStart = b.start } - lastStart = b.start + if iters == 1 { + scaledStart = b.start + } iters++ } finalBN = b.N @@ -45,8 +47,8 @@ func TestBenchmarkBLoop(t *T) { if firstStart == initialStart { t.Errorf("b.Loop did not reset the timer") } - if lastStart != firstStart { - t.Errorf("timer was reset during iteration") + if scaledStart != firstStart { + t.Errorf("b.Loop stops and restarts the timer during iteration") } // Verify that it stopped the timer after the last loop. if runningEnd { |
