gonum.org/v1/gonum@v0.14.0/internal/asm/c128/benchDot_test.go (about) 1 // Copyright ©2017 The Gonum Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package c128 6 7 import ( 8 "fmt" 9 "testing" 10 ) 11 12 func BenchmarkDotUnitary(t *testing.B) { 13 for _, test := range []struct { 14 name string 15 f func(x, y []complex128) complex128 16 }{ 17 {"DotcUnitary", DotcUnitary}, 18 {"DotuUnitary", DotuUnitary}, 19 } { 20 for _, v := range []int64{1, 2, 3, 4, 5, 10, 100, 1e3, 5e3, 1e4, 5e4} { 21 t.Run(fmt.Sprintf("%s-%d", test.name, v), func(b *testing.B) { 22 x, y := x[:v], y[:v] 23 b.SetBytes(256 * v) 24 for i := 0; i < b.N; i++ { 25 benchSink = test.f(x, y) 26 } 27 }) 28 } 29 } 30 } 31 32 func BenchmarkDotInc(t *testing.B) { 33 for _, test := range []struct { 34 name string 35 f func(x, y []complex128, n, incX, incY, ix, iy uintptr) complex128 36 }{ 37 {"DotcInc", DotcInc}, 38 {"DotuInc", DotuInc}, 39 } { 40 for _, ln := range []int{1, 2, 3, 4, 5, 10, 100, 1e3, 5e3, 1e4, 5e4} { 41 for _, inc := range []int{1, 2, 4, 10, -1, -2, -4, -10} { 42 t.Run(fmt.Sprintf("%s-%d-inc%d", test.name, ln, inc), func(b *testing.B) { 43 b.SetBytes(int64(256 * ln)) 44 var idx int 45 if inc < 0 { 46 idx = (-ln + 1) * inc 47 } 48 for i := 0; i < b.N; i++ { 49 benchSink = test.f(x, y, uintptr(ln), 50 uintptr(inc), uintptr(inc), 51 uintptr(idx), uintptr(idx)) 52 } 53 }) 54 } 55 } 56 } 57 }