diff options
author | Brad Fitzpatrick <bradfitz@golang.org> | 2012-02-02 11:49:28 -0800 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@golang.org> | 2012-02-02 11:49:28 -0800 |
commit | 7f3ba358875ed0a462a04a4614cf405384548cbf (patch) | |
tree | 41d4f650c0e079fa8e93467257585ef93eafd905 | |
parent | 17679a3af40b94546f4259a430266157aa2b0bb5 (diff) | |
download | go-7f3ba358875ed0a462a04a4614cf405384548cbf.tar.gz |
test: make map nan timing test more robust
take 2
R=rsc
CC=golang-dev
http://codereview.appspot.com/5617045
-rw-r--r-- | test/map.go | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/test/map.go b/test/map.go index a92586ff4..215e56c7f 100644 --- a/test/map.go +++ b/test/map.go @@ -667,10 +667,25 @@ func testnan() { return time.Since(t0) } - n := 60000 // 0.04 seconds on a MacBook Air - t1 := t(n) - t2 := t(2 * n) - if t2 > 3*t1 { // should be 2x (linear); allow up to 3x - fmt.Printf("too slow: %d inserts: %v; %d inserts: %v\n", n, t1, 2*n, t2) + // Depending on the machine and OS, this test might be too fast + // to measure with accurate enough granularity. On failure, + // make it run longer, hoping that the timing granularity + // is eventually sufficient. + + n := 30000 // 0.02 seconds on a MacBook Air + fails := 0 + for { + t1 := t(n) + t2 := t(2 * n) + // should be 2x (linear); allow up to 3x + if t2 < 3*t1 { + return + } + fails++ + if fails == 4 { + fmt.Printf("too slow: %d inserts: %v; %d inserts: %v\n", n, t1, 2*n, t2) + return + } + n *= 2 } } |