diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-06-10 11:45:16 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-06-10 11:45:16 -0700 |
commit | 6d43ac9574a16b09a6e6bc9907d4a0270be54b2f (patch) | |
tree | 969f1fb8d6c5ecd7a3264c9bf846d6670d3173d8 /pkg/sentry/time/parameters_test.go | |
parent | f004bb8703b516a423e05111e8d0fc55b1a850d8 (diff) | |
parent | 6acd185bd3c04d6d6f57ccc9335513abaadf0651 (diff) |
Merge pull request #2787 from lubinszARM:pr_race_time
PiperOrigin-RevId: 315734425
Diffstat (limited to 'pkg/sentry/time/parameters_test.go')
-rw-r--r-- | pkg/sentry/time/parameters_test.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/pkg/sentry/time/parameters_test.go b/pkg/sentry/time/parameters_test.go index e1b9084ac..0ce1257f6 100644 --- a/pkg/sentry/time/parameters_test.go +++ b/pkg/sentry/time/parameters_test.go @@ -484,3 +484,18 @@ func TestMulDivOverflow(t *testing.T) { }) } } + +func BenchmarkMuldiv64(b *testing.B) { + var v uint64 = math.MaxUint64 + for i := uint64(1); i <= 1000000; i++ { + mult := uint64(1000000000) + div := i * mult + res, ok := muldiv64(v, mult, div) + if !ok { + b.Errorf("Result of %v * %v / %v ok got false want true", v, mult, div) + } + if want := v / i; res != want { + b.Errorf("Bad result of %v * %v / %v: got %v, want %v", v, mult, div, res, want) + } + } +} |