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.
17 func BenchmarkDotUnitary(t *testing.B) {
18 const name = "DotUnitary"
19 for _, v := range []int64{1, 2, 3, 4, 5, 10, 100, 1e3, 5e3, 1e4, 5e4} {
20 t.Run(fmt.Sprintf("%s-%d", name, v), func(b *testing.B) {
23 for i := 0; i < b.N; i++ {
24 benchSink = DotUnitary(x, y)
30 func BenchmarkDdotUnitary(t *testing.B) {
31 const name = "DdotUnitary"
32 for _, v := range []int64{1, 2, 3, 4, 5, 10, 100, 1e3, 5e3, 1e4, 5e4} {
33 t.Run(fmt.Sprintf("%s-%d", name, v), func(b *testing.B) {
36 for i := 0; i < b.N; i++ {
37 benchSink64 = DdotUnitary(x, y)
43 var incsDot = []struct {
48 {3, []int{1, 2, 4, 10}},
49 {10, []int{1, 2, 4, 10}},
50 {30, []int{1, 2, 4, 10}},
51 {1e2, []int{1, 2, 4, 10}},
52 {3e2, []int{1, 2, 4, 10}},
53 {1e3, []int{1, 2, 4, 10}},
54 {3e3, []int{1, 2, 4, 10}},
55 {1e4, []int{1, 2, 4, 10, -1, -2, -4, -10}},
58 func BenchmarkDotInc(t *testing.B) {
60 for _, tt := range incsDot {
61 for _, inc := range tt.inc {
62 t.Run(fmt.Sprintf("%s-%d-inc(%d)", name, tt.len, inc), func(b *testing.B) {
63 b.SetBytes(int64(32 * tt.len))
66 idx = (-tt.len + 1) * inc
68 for i := 0; i < b.N; i++ {
69 benchSink = DotInc(x, y, uintptr(tt.len), uintptr(inc), uintptr(inc), uintptr(idx), uintptr(idx))
76 func BenchmarkDdotInc(t *testing.B) {
77 const name = "DdotInc"
78 for _, tt := range incsDot {
79 for _, inc := range tt.inc {
80 t.Run(fmt.Sprintf("%s-%d-inc(%d)", name, tt.len, inc), func(b *testing.B) {
81 b.SetBytes(int64(32 * tt.len))
84 idx = (-tt.len + 1) * inc
86 for i := 0; i < b.N; i++ {
87 benchSink64 = DdotInc(x, y, uintptr(tt.len), uintptr(inc), uintptr(inc), uintptr(idx), uintptr(idx))