]> Cypherpunks repositories - gostls13.git/commitdiff
math/big: cut 2 minutes off race tests
authorBrad Fitzpatrick <bradfitz@golang.org>
Wed, 14 Sep 2016 18:44:59 +0000 (18:44 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 14 Sep 2016 19:11:43 +0000 (19:11 +0000)
No need to test so many sizes in race mode, especially for a package
which doesn't use goroutines.

Reduces test time from 2.5 minutes to 25 seconds.

Updates #17104

Change-Id: I7065b39273f82edece385c0d67b3f2d83d4934b8
Reviewed-on: https://go-review.googlesource.com/29163
Reviewed-by: David Crawshaw <crawshaw@golang.org>
src/math/big/arith_test.go
src/math/big/gcd_test.go
src/math/big/int_test.go
src/math/big/natconv_test.go

index 75862b4951fffe64b5900f16a2e2dd31d4891446..f2b308300093f42d33dbdabe32e06a97b79c3ec4 100644 (file)
@@ -6,10 +6,14 @@ package big
 
 import (
        "fmt"
+       "internal/testenv"
        "math/rand"
+       "strings"
        "testing"
 )
 
+var isRaceBuilder = strings.HasSuffix(testenv.Builder(), "-race")
+
 type funWW func(x, y, c Word) (z1, z0 Word)
 type argWW struct {
        x, y, c, z1, z0 Word
@@ -123,6 +127,9 @@ var benchSizes = []int{1, 2, 3, 4, 5, 1e1, 1e2, 1e3, 1e4, 1e5}
 
 func BenchmarkAddVV(b *testing.B) {
        for _, n := range benchSizes {
+               if isRaceBuilder && n > 1e3 {
+                       continue
+               }
                x := rndV(n)
                y := rndV(n)
                z := make([]Word, n)
@@ -233,6 +240,9 @@ func TestFunVW(t *testing.T) {
 
 func BenchmarkAddVW(b *testing.B) {
        for _, n := range benchSizes {
+               if isRaceBuilder && n > 1e3 {
+                       continue
+               }
                x := rndV(n)
                y := rndW()
                z := make([]Word, n)
@@ -371,6 +381,9 @@ func TestMulAddWWW(t *testing.T) {
 
 func BenchmarkAddMulVVW(b *testing.B) {
        for _, n := range benchSizes {
+               if isRaceBuilder && n > 1e3 {
+                       continue
+               }
                x := rndV(n)
                y := rndW()
                z := make([]Word, n)
index a929bf597f42da91997ed062afe7592f5809dc17..3cca2ecd0c821aafc46d10e53e9e853526589d9a 100644 (file)
@@ -20,6 +20,9 @@ func randInt(r *rand.Rand, size uint) *Int {
 }
 
 func runGCD(b *testing.B, aSize, bSize uint) {
+       if isRaceBuilder && (aSize > 1000 || bSize > 1000) {
+               b.Skip("skipping on race builder")
+       }
        b.Run("WithoutXY", func(b *testing.B) {
                runGCDExt(b, aSize, bSize, false)
        })
index 45a3765d3eee36d9669d7c5fda9211836b123ee0..fcc2ebc9ba3dac429c80fb5138b372ea6d4f4599 100644 (file)
@@ -1229,6 +1229,9 @@ func BenchmarkModSqrt224_3Mod4(b *testing.B) {
 }
 
 func BenchmarkModSqrt5430_Tonelli(b *testing.B) {
+       if isRaceBuilder {
+               b.Skip("skipping on race builder")
+       }
        p := tri(5430)
        x := new(Int).SetUint64(2)
        for i := 0; i < b.N; i++ {
@@ -1238,6 +1241,9 @@ func BenchmarkModSqrt5430_Tonelli(b *testing.B) {
 }
 
 func BenchmarkModSqrt5430_3Mod4(b *testing.B) {
+       if isRaceBuilder {
+               b.Skip("skipping on race builder")
+       }
        p := tri(5430)
        x := new(Int).SetUint64(2)
        for i := 0; i < b.N; i++ {
index 79901d1880477fe6f402f9f95240e1e250d38a7e..bdb60e68e0a711ed242555607ff5743f5c87e092 100644 (file)
@@ -278,6 +278,9 @@ func BenchmarkScan(b *testing.B) {
        const x = 10
        for _, base := range []int{2, 8, 10, 16} {
                for _, y := range []Word{10, 100, 1000, 10000, 100000} {
+                       if isRaceBuilder && y > 1000 {
+                               continue
+                       }
                        b.Run(fmt.Sprintf("%d/Base%d", y, base), func(b *testing.B) {
                                b.StopTimer()
                                var z nat
@@ -301,6 +304,9 @@ func BenchmarkString(b *testing.B) {
        const x = 10
        for _, base := range []int{2, 8, 10, 16} {
                for _, y := range []Word{10, 100, 1000, 10000, 100000} {
+                       if isRaceBuilder && y > 1000 {
+                               continue
+                       }
                        b.Run(fmt.Sprintf("%d/Base%d", y, base), func(b *testing.B) {
                                b.StopTimer()
                                var z nat