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/benchmark.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/benchmark.go')
| -rw-r--r-- | src/testing/benchmark.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/testing/benchmark.go b/src/testing/benchmark.go index 6919341ef7..ca12bd2fa2 100644 --- a/src/testing/benchmark.go +++ b/src/testing/benchmark.go @@ -368,8 +368,8 @@ func (b *B) ReportMetric(n float64, unit string) { } func (b *B) stopOrScaleBLoop() bool { - timeElapsed := highPrecisionTimeSince(b.start) - if timeElapsed >= b.benchTime.d { + t := b.Elapsed() + if t >= b.benchTime.d { // Stop the timer so we don't count cleanup time b.StopTimer() return false @@ -377,7 +377,7 @@ func (b *B) stopOrScaleBLoop() bool { // Loop scaling goalns := b.benchTime.d.Nanoseconds() prevIters := int64(b.N) - b.N = predictN(goalns, prevIters, timeElapsed.Nanoseconds(), prevIters) + b.N = predictN(goalns, prevIters, t.Nanoseconds(), prevIters) b.loopN++ return true } |
