]> Cypherpunks.ru repositories - gostls13.git/blobdiff - test/maplinear.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / test / maplinear.go
index 2494becb89ca95ac1660b580a83242e7127996cb..dbc68272bf054601d88f6057866bce874bf451f7 100644 (file)
@@ -1,6 +1,7 @@
-// +build darwin linux
 // run
 
+//go:build darwin || linux
+
 // Copyright 2013 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
@@ -44,14 +45,21 @@ func checkLinear(typ string, tries int, f func(n int)) {
                        }
                        return
                }
-               fails++
-               if fails == 12 {
+               // If n ops run in under a second and the ratio
+               // doesn't work out, make n bigger, trying to reduce
+               // the effect that a constant amount of overhead has
+               // on the computed ratio.
+               if t1 < 1*time.Second {
+                       n *= 2
+                       continue
+               }
+               // Once the test runs long enough for n ops,
+               // try to get the right ratio at least once.
+               // If five in a row all fail, give up.
+               if fails++; fails >= 5 {
                        panic(fmt.Sprintf("%s: too slow: %d inserts: %v; %d inserts: %v\n",
                                typ, n, t1, 2*n, t2))
                }
-               if fails < 10 {
-                       n *= 2
-               }
        }
 }