benchmark histogram
Blake Mizerany
10 years ago
0 | package histogram | |
1 | ||
2 | import ( | |
3 | "testing" | |
4 | "math/rand" | |
5 | ) | |
6 | ||
7 | func BenchmarkInsert10Bins(b *testing.B) { | |
8 | b.StopTimer() | |
9 | h := New(10) | |
10 | b.StartTimer() | |
11 | for i := 0; i < b.N; i++ { | |
12 | f := rand.ExpFloat64() | |
13 | h.Insert(f) | |
14 | } | |
15 | } | |
16 | ||
17 | func BenchmarkInsert100Bins(b *testing.B) { | |
18 | b.StopTimer() | |
19 | h := New(100) | |
20 | b.StartTimer() | |
21 | for i := 0; i < b.N; i++ { | |
22 | f := rand.ExpFloat64() | |
23 | h.Insert(f) | |
24 | } | |
25 | } |