-
Notifications
You must be signed in to change notification settings - Fork 8
/
geiger_test.go
65 lines (62 loc) · 913 Bytes
/
geiger_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
package geiger
import (
"bytes"
"io"
"io/ioutil"
"testing"
"time"
)
// TestCount requires human ears.
func TestCount(t *testing.T) {
go Count()
tests := []struct {
name string
hz int
per int
}{
{
name: "baseline",
hz: 1,
per: 0,
},
{
name: "5hz",
hz: 5,
per: 1,
}, {
name: "50hz",
hz: 50,
per: 1,
}, {
name: "500hz",
hz: 50,
per: 10,
}, {
name: "5000hz",
hz: 50,
per: 100,
}, {
name: "50000hz",
hz: 50,
per: 1000,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
done := time.After(5 * time.Second)
every := time.NewTicker(time.Second / time.Duration(tt.hz))
for {
select {
case <-done:
return
case <-every.C:
for i := 0; i < tt.per; i++ {
// alloc tmp
tmp := bytes.Buffer{}
io.Copy(ioutil.Discard, &tmp)
}
}
}
})
}
}