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.
12 var uniScal = []int64{1, 3, 10, 30, 1e2, 3e2, 1e3, 3e3, 1e4, 3e4}
14 func BenchmarkScalUnitary(t *testing.B) {
15 tstName := "ScalUnitary"
16 for _, ln := range uniScal {
17 t.Run(fmt.Sprintf("%s-%d", tstName, ln), func(b *testing.B) {
21 for i := 0; i < b.N; i++ {
28 func BenchmarkScalUnitaryTo(t *testing.B) {
29 tstName := "ScalUnitaryTo"
30 for _, ln := range uniScal {
31 t.Run(fmt.Sprintf("%s-%d", tstName, ln), func(b *testing.B) {
32 b.SetBytes(int64(64 * ln))
33 x, y := x[:ln], y[:ln]
35 for i := 0; i < b.N; i++ {
36 ScalUnitaryTo(y, a, x)
42 var incScal = []struct {
47 {3, []int{1, 2, 4, 10}},
48 {10, []int{1, 2, 4, 10}},
49 {30, []int{1, 2, 4, 10}},
50 {1e2, []int{1, 2, 4, 10}},
51 {3e2, []int{1, 2, 4, 10}},
52 {1e3, []int{1, 2, 4, 10}},
53 {3e3, []int{1, 2, 4, 10}},
54 {1e4, []int{1, 2, 4, 10}},
57 func BenchmarkScalInc(t *testing.B) {
59 for _, tt := range incScal {
60 for _, inc := range tt.inc {
61 t.Run(fmt.Sprintf("%s-%d-inc(%d)", tstName, tt.len, inc), func(b *testing.B) {
62 b.SetBytes(int64(64 * tt.len))
63 tstInc := uintptr(inc)
64 for i := 0; i < b.N; i++ {
65 ScalInc(a, x, uintptr(tt.len), tstInc)
72 func BenchmarkScalIncTo(t *testing.B) {
73 tstName := "ScalIncTo"
74 for _, tt := range incScal {
75 for _, inc := range tt.inc {
76 t.Run(fmt.Sprintf("%s-%d-inc(%d)", tstName, tt.len, inc), func(b *testing.B) {
77 b.SetBytes(int64(64 * tt.len))
78 tstInc := uintptr(inc)
79 for i := 0; i < b.N; i++ {
80 ScalIncTo(z, tstInc, a, x, uintptr(tt.len), tstInc)