diff options
Diffstat (limited to 'test/maplinear.go')
-rw-r--r-- | test/maplinear.go | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/test/maplinear.go b/test/maplinear.go index 06da968ef..34d091491 100644 --- a/test/maplinear.go +++ b/test/maplinear.go @@ -44,14 +44,21 @@ func checkLinear(typ string, tries int, f func(n int)) { } return } - fails++ - if fails == 6 { + // If n ops run in under a second and the ratio + // doesn't work out, make n bigger, trying to reduce + // the effect that a constant amount of overhead has + // on the computed ratio. + if t1 < 1*time.Second { + n *= 2 + continue + } + // Once the test runs long enough for n ops, + // try to get the right ratio at least once. + // If five in a row all fail, give up. + if fails++; fails >= 5 { panic(fmt.Sprintf("%s: too slow: %d inserts: %v; %d inserts: %v\n", typ, n, t1, 2*n, t2)) } - if fails < 4 { - n *= 2 - } } } |