]> Cypherpunks repositories - gostls13.git/commit
testing: fix divide by zero when benchmark is faster than OS's clock resolution
authorJorropo <jorropo.pgm@gmail.com>
Fri, 6 Dec 2024 05:51:04 +0000 (06:51 +0100)
committerGopher Robot <gobot@golang.org>
Fri, 6 Dec 2024 06:25:44 +0000 (06:25 +0000)
commitd3d4e7b0d10d5587093b769ed600bd3b0a3fd9c1
treefa6a890628db701325f807af5f73bee8ed3dc713
parent3ae00f5d29e896d727670ca6414e84b0cd9ec0bc
testing: fix divide by zero when benchmark is faster than OS's clock resolution

I did not added a test because `benchmark_test.go` is `package testing_test`
and I don't care to change that because calling predictN is not testing the
thing I would want to test.

Ideally we would run benchmark in a VM with a highjacked clocksource that never
marches forward, or using faketime but that looks fairly involved for a quickie
fix.

Fixes #70709

Change-Id: I8b4d697aff7cba33da388cb0ae8e2c2b550b9690
Reviewed-on: https://go-review.googlesource.com/c/go/+/633419
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
src/testing/benchmark.go