forked from mna/gocostmodel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
math_test.go
75 lines (63 loc) · 1.13 KB
/
math_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package gocostmodel
import (
"math"
"math/rand"
"testing"
)
var (
neg float64 = -3.456
mathv1 float64 = 6.4
mathv2 float64 = 1.2
out float64
outi int
)
func BenchmarkMathAbs(b *testing.B) {
for i := 0; i < b.N; i++ {
out = math.Abs(neg)
}
}
func BenchmarkMathCos(b *testing.B) {
for i := 0; i < b.N; i++ {
out = math.Cos(mathv1)
}
}
func BenchmarkMathSin(b *testing.B) {
for i := 0; i < b.N; i++ {
out = math.Sin(mathv1)
}
}
func BenchmarkMathPow(b *testing.B) {
for i := 0; i < b.N; i++ {
out = math.Pow(mathv1, mathv2)
}
}
func BenchmarkMathLog(b *testing.B) {
for i := 0; i < b.N; i++ {
out = math.Log(mathv1)
}
}
func BenchmarkMathExp(b *testing.B) {
for i := 0; i < b.N; i++ {
out = math.Exp(mathv1)
}
}
func BenchmarkMathSqrt(b *testing.B) {
for i := 0; i < b.N; i++ {
out = math.Sqrt(mathv1)
}
}
func BenchmarkMathMax(b *testing.B) {
for i := 0; i < b.N; i++ {
out = math.Max(mathv1, mathv2)
}
}
func BenchmarkMathMin(b *testing.B) {
for i := 0; i < b.N; i++ {
out = math.Min(mathv1, mathv2)
}
}
func BenchmarkMathRand(b *testing.B) {
for i := 0; i < b.N; i++ {
outi = rand.Int()
}
}