summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2016-05-25 17:29:56 -0700
committerRobert Griesemer <gri@golang.org>2016-05-26 16:27:24 +0000
commit2168f2a68bb438996d14869ff7dd10a47cc0552c (patch)
treee68581fb0c5aecbf2b383479bef50488f8e81ac8
parent56e5e0b69c92c9157c7db39112e27a4b5c026b48 (diff)
downloadgo-git-2168f2a68bb438996d14869ff7dd10a47cc0552c.tar.gz
math/big: simplify benchmarking code some more
Follow-up cleanup to https://golang.org/cl/23424/ . Change-Id: Ifb05c1ff5327df6bc5f4cbc554e18363293f7960 Reviewed-on: https://go-review.googlesource.com/23446 Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
-rw-r--r--src/math/big/arith_test.go48
1 files changed, 17 insertions, 31 deletions
diff --git a/src/math/big/arith_test.go b/src/math/big/arith_test.go
index 94e5f5ca87..75862b4951 100644
--- a/src/math/big/arith_test.go
+++ b/src/math/big/arith_test.go
@@ -119,29 +119,15 @@ func rndV(n int) []Word {
return v
}
-var benchSizes = []struct {
- name string
- n int
-}{
- {"1", 1},
- {"2", 2},
- {"3", 3},
- {"4", 4},
- {"5", 5},
- {"1e1", 1e1},
- {"1e2", 1e2},
- {"1e3", 1e3},
- {"1e4", 1e4},
- {"1e5", 1e5},
-}
+var benchSizes = []int{1, 2, 3, 4, 5, 1e1, 1e2, 1e3, 1e4, 1e5}
func BenchmarkAddVV(b *testing.B) {
- for _, tc := range benchSizes {
- x := rndV(tc.n)
- y := rndV(tc.n)
- z := make([]Word, tc.n)
- b.Run(fmt.Sprint(tc.name), func(b *testing.B) {
- b.SetBytes(int64(tc.n * _W))
+ for _, n := range benchSizes {
+ x := rndV(n)
+ y := rndV(n)
+ z := make([]Word, n)
+ b.Run(fmt.Sprint(n), func(b *testing.B) {
+ b.SetBytes(int64(n * _W))
for i := 0; i < b.N; i++ {
addVV(z, x, y)
}
@@ -246,12 +232,12 @@ func TestFunVW(t *testing.T) {
}
func BenchmarkAddVW(b *testing.B) {
- for _, tc := range benchSizes {
- x := rndV(tc.n)
+ for _, n := range benchSizes {
+ x := rndV(n)
y := rndW()
- z := make([]Word, tc.n)
- b.Run(fmt.Sprint(tc.name), func(b *testing.B) {
- b.SetBytes(int64(tc.n * _S))
+ z := make([]Word, n)
+ b.Run(fmt.Sprint(n), func(b *testing.B) {
+ b.SetBytes(int64(n * _S))
for i := 0; i < b.N; i++ {
addVW(z, x, y)
}
@@ -384,12 +370,12 @@ func TestMulAddWWW(t *testing.T) {
}
func BenchmarkAddMulVVW(b *testing.B) {
- for _, tc := range benchSizes {
- x := rndV(tc.n)
+ for _, n := range benchSizes {
+ x := rndV(n)
y := rndW()
- z := make([]Word, tc.n)
- b.Run(fmt.Sprint(tc.n), func(b *testing.B) {
- b.SetBytes(int64(tc.n * _W))
+ z := make([]Word, n)
+ b.Run(fmt.Sprint(n), func(b *testing.B) {
+ b.SetBytes(int64(n * _W))
for i := 0; i < b.N; i++ {
addMulVVW(z, x, y)
}