Skip to content

Commit

Permalink
math/big: cut 2 minutes off race tests
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
bradfitz committed Sep 14, 2016
1 parent 983e2fd commit 6f135bf
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/math/big/arith_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions src/math/big/gcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
6 changes: 6 additions & 0 deletions src/math/big/int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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++ {
Expand All @@ -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++ {
Expand Down
6 changes: 6 additions & 0 deletions src/math/big/natconv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 6f135bf

Please sign in to comment.