mirror of
https://github.com/golang/go
synced 2024-11-12 05:40:22 -07:00
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>
This commit is contained in:
parent
56e5e0b69c
commit
2168f2a68b
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user