Commit 92cf05da authored by Russ Cox's avatar Russ Cox

test: deflake locklinear again

Fixes #19276.

Change-Id: I64f8f80331d09956b6698c0b004ed7f7d70857fc
Reviewed-on: https://go-review.googlesource.com/39591
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarJosh Bleecher Snyder <josharian@gmail.com>
parent 10991fd5
...@@ -38,17 +38,25 @@ func checkLinear(typ string, tries int, f func(n int)) { ...@@ -38,17 +38,25 @@ func checkLinear(typ string, tries int, f func(n int)) {
n := tries n := tries
fails := 0 fails := 0
var buf bytes.Buffer var buf bytes.Buffer
inversions := 0
for { for {
t1 := timeF(n) t1 := timeF(n)
t2 := timeF(2 * n) t2 := timeF(2 * n)
if debug { if debug {
println(n, t1.String(), 2*n, t2.String()) println(n, t1.String(), 2*n, t2.String())
} }
fmt.Fprintf(&buf, "%d %v %d %v\n", n, t1, 2*n, t2) fmt.Fprintf(&buf, "%d %v %d %v (%.1fX)\n", n, t1, 2*n, t2, float64(t2)/float64(t1))
// should be 2x (linear); allow up to 2.5x // should be 2x (linear); allow up to 3x
if t1*3/2 < t2 && t2 < t1*5/2 { if t1*3/2 < t2 && t2 < t1*3 {
return return
} }
if t2 < t1 {
if inversions++; inversions >= 5 {
// The system must be overloaded (some builders). Give up.
return
}
continue // try again; don't increment fails
}
// Once the test runs long enough for n ops, // Once the test runs long enough for n ops,
// try to get the right ratio at least once. // try to get the right ratio at least once.
// If many in a row all fail, give up. // If many in a row all fail, give up.
......
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