mirror of
https://github.com/golang/go
synced 2024-11-21 22:44:40 -07:00
test: make map nan timing test more robust
take 2 R=rsc CC=golang-dev https://golang.org/cl/5617045
This commit is contained in:
parent
e10150f96d
commit
69a5b23dc5
25
test/map.go
25
test/map.go
@ -667,10 +667,25 @@ func testnan() {
|
|||||||
return time.Since(t0)
|
return time.Since(t0)
|
||||||
}
|
}
|
||||||
|
|
||||||
n := 60000 // 0.04 seconds on a MacBook Air
|
// Depending on the machine and OS, this test might be too fast
|
||||||
t1 := t(n)
|
// to measure with accurate enough granularity. On failure,
|
||||||
t2 := t(2 * n)
|
// make it run longer, hoping that the timing granularity
|
||||||
if t2 > 3*t1 { // should be 2x (linear); allow up to 3x
|
// is eventually sufficient.
|
||||||
fmt.Printf("too slow: %d inserts: %v; %d inserts: %v\n", n, t1, 2*n, t2)
|
|
||||||
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user