Commit 6f135bfd authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

math/big: cut 2 minutes off race tests

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