Commit f197988c authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

test: make maplinear iterdelete test less flaky

iterdelete's run time varies; occasionally we get unlucky. To reduce spurious failures, average away some of the variation.

On my machine, 8 of 5000 runs (0.15%) failed before this CL. After this CL, there were no failures after 35,000 runs.

I confirmed that this adjusted test still fails before CL 141270043.

LGTM=khr
R=khr
CC=bradfitz, golang-codereviews
https://golang.org/cl/140610043
parent e024ed5c
......@@ -146,15 +146,19 @@ func main() {
// O(n lg n) time. Fortunately, the checkLinear test
// leaves enough wiggle room to include n lg n time
// (it actually tests for O(n^log_2(3)).
checkLinear("iterdelete", 10000, func(n int) {
m := map[int]int{}
for i := 0; i < n; i++ {
m[i] = i
}
for i := 0; i < n; i++ {
for k := range m {
delete(m, k)
break
// To prevent false positives, average away variation
// by doing multiple rounds within a single run.
checkLinear("iterdelete", 2500, func(n int) {
for round := 0; round < 4; round++ {
m := map[int]int{}
for i := 0; i < n; i++ {
m[i] = i
}
for i := 0; i < n; i++ {
for k := range m {
delete(m, k)
break
}
}
}
})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment