-
Notifications
You must be signed in to change notification settings - Fork 4
/
oscil_test.go
83 lines (75 loc) · 1.69 KB
/
oscil_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
76
77
78
79
80
81
82
83
package snd
import (
"testing"
"dasa.cc/signal"
)
func BenchmarkOscil(b *testing.B) {
osc := NewOscil(signal.Sine(), 440, nil)
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
osc.Prepare(uint64(n))
}
}
func BenchmarkOscilMod(b *testing.B) {
osc := NewOscil(signal.Sine(), 440, NewOscil(signal.Sine(), 2, nil))
inps := GetInputs(osc)
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
for _, inp := range inps {
inp.sd.Prepare(uint64(n))
}
}
}
func BenchmarkOscilAmp(b *testing.B) {
osc := NewOscil(signal.Sine(), 440, nil)
osc.SetAmp(1, NewOscil(signal.Sine(), 2, nil))
inps := GetInputs(osc)
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
for _, inp := range inps {
inp.sd.Prepare(uint64(n))
}
}
}
func BenchmarkOscilPhase(b *testing.B) {
osc := NewOscil(signal.Sine(), 440, nil)
osc.SetPhase(NewOscil(signal.Sine(), 2, nil))
inps := GetInputs(osc)
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
for _, inp := range inps {
inp.sd.Prepare(uint64(n))
}
}
}
func BenchmarkOscilAll(b *testing.B) {
osc := NewOscil(signal.Sine(), 440, NewOscil(signal.Sine(), 2, nil))
osc.SetAmp(1, NewOscil(signal.Sine(), 2, nil))
osc.SetPhase(NewOscil(signal.Sine(), 2, nil))
inps := GetInputs(osc)
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
for _, inp := range inps {
inp.sd.Prepare(uint64(n))
}
}
}
func BenchmarkOscilReuse(b *testing.B) {
mod := NewOscil(signal.Sine(), 2, nil)
osc := NewOscil(signal.Sine(), 440, mod)
osc.SetAmp(1, mod)
osc.SetPhase(mod)
inps := GetInputs(osc)
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
for _, inp := range inps {
inp.sd.Prepare(uint64(n))
}
}
}