OSDN Git Service

new repo
[bytom/vapor.git] / vendor / gonum.org / v1 / gonum / internal / asm / f64 / benchScal_test.go
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 f64
6
7 import (
8         "fmt"
9         "testing"
10 )
11
12 var uniScal = []int64{1, 3, 10, 30, 1e2, 3e2, 1e3, 3e3, 1e4, 3e4}
13
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) {
18                         b.SetBytes(64 * ln)
19                         x := x[:ln]
20                         b.ResetTimer()
21                         for i := 0; i < b.N; i++ {
22                                 ScalUnitary(a, x)
23                         }
24                 })
25         }
26 }
27
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]
34                         b.ResetTimer()
35                         for i := 0; i < b.N; i++ {
36                                 ScalUnitaryTo(y, a, x)
37                         }
38                 })
39         }
40 }
41
42 var incScal = []struct {
43         len uintptr
44         inc []int
45 }{
46         {1, []int{1}},
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}},
55 }
56
57 func BenchmarkScalInc(t *testing.B) {
58         tstName := "ScalInc"
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)
66                                 }
67                         })
68                 }
69         }
70 }
71
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)
81                                 }
82                         })
83                 }
84         }
85 }