aboutsummaryrefslogtreecommitdiff
path: root/test/locklinear.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2017-04-05 09:56:39 -0400
committerRuss Cox <rsc@golang.org>2017-04-05 18:46:31 +0000
commit92cf05daf3c96c854f8e2a32d6734a91ef7bb865 (patch)
tree941d9fb467f4f6f23eda219ebf7f5da3ca3d04ac /test/locklinear.go
parent10991fd5af24fd01483ab23c9b3d7de52de580b2 (diff)
downloadgo-92cf05daf3c96c854f8e2a32d6734a91ef7bb865.tar.gz
go-92cf05daf3c96c854f8e2a32d6734a91ef7bb865.zip
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: Josh Bleecher Snyder <josharian@gmail.com>
Diffstat (limited to 'test/locklinear.go')
-rw-r--r--test/locklinear.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/test/locklinear.go b/test/locklinear.go
index f1e912a2a3..161912b65e 100644
--- a/test/locklinear.go
+++ b/test/locklinear.go
@@ -38,17 +38,25 @@ func checkLinear(typ string, tries int, f func(n int)) {
n := tries
fails := 0
var buf bytes.Buffer
+ inversions := 0
for {
t1 := timeF(n)
t2 := timeF(2 * n)
if debug {
println(n, t1.String(), 2*n, t2.String())
}
- fmt.Fprintf(&buf, "%d %v %d %v\n", n, t1, 2*n, t2)
- // should be 2x (linear); allow up to 2.5x
- if t1*3/2 < t2 && t2 < t1*5/2 {
+ 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 3x
+ if t1*3/2 < t2 && t2 < t1*3 {
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,
// try to get the right ratio at least once.
// If many in a row all fail, give up.