-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfixed_test.go
More file actions
100 lines (74 loc) · 1.67 KB
/
Copy pathfixed_test.go
File metadata and controls
100 lines (74 loc) · 1.67 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package analytic
import (
"fmt"
"testing"
"github.com/ready-steady/assert"
"github.com/ready-steady/fixture"
)
func TestFixedNew(t *testing.T) {
const (
nc = 2
)
temperature, _ := loadFixed(nc)
assert.Equal(temperature.nc, uint(nc), t)
assert.Equal(temperature.nn, uint(4*nc+12), t)
assert.Close(temperature.D, fixtureD, 1e-14, t)
assert.Close(temperature.E, fixtureE, 1e-9, t)
assert.Close(temperature.F, fixtureF, 1e-9, t)
}
func TestFixedCompute(t *testing.T) {
const (
nc = 2
)
temperature, P := loadFixed(nc)
Q := temperature.Compute(P)
assert.Close(Q, fixtureQ, 1e-12, t)
}
func TestFixedComputeWithStatic(t *testing.T) {
const (
nc = 2
)
temperature, P := loadFixed(nc)
noop := func([]float64, []float64) {}
Q := temperature.ComputeWithStatic(P, noop)
assert.Close(Q, fixtureQ, 1e-12, t)
}
func BenchmarkFixedCompute002(b *testing.B) {
const (
nc = 2
)
temperature, P := loadFixed(nc)
b.ResetTimer()
for i := 0; i < b.N; i++ {
temperature.Compute(P)
}
}
func BenchmarkFixedComputeWithStatic002(b *testing.B) {
const (
nc = 2
)
temperature, P := loadFixed(nc)
noop := func([]float64, []float64) {}
b.ResetTimer()
for i := 0; i < b.N; i++ {
temperature.ComputeWithStatic(P, noop)
}
}
func BenchmarkFixedCompute032(b *testing.B) {
const (
nc = 32
ns = 1000
)
temperature, _ := loadFixed(nc)
P := random(nc*ns, 0, 20)
b.ResetTimer()
for i := 0; i < b.N; i++ {
temperature.Compute(P)
}
}
func loadFixed(nc uint) (*Fixed, []float64) {
config := &Config{}
fixture.Load(findFixture(fmt.Sprintf("%03d.json", nc)), config)
temperature, _ := NewFixed(config)
return temperature, append([]float64(nil), fixtureP...)
}