-
Notifications
You must be signed in to change notification settings - Fork 0
/
merkle_bench_test.go
53 lines (45 loc) · 927 Bytes
/
merkle_bench_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
package gomerkt
import (
"math/rand"
"testing"
"time"
)
var contents []Content
var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
var iterations = 10000
func init() {
rand.Seed(time.Now().UnixNano())
for i := 0; i < 10000; i++ {
contents = append(contents,
TestSHA256Content{
RandStringRunes(5),
})
}
}
func RandStringRunes(n int) string {
b := make([]rune, n)
for i := range b {
b[i] = letterRunes[rand.Intn(len(letterRunes))]
}
return string(b)
}
func BenchmarkNewTree(b *testing.B) {
for i := 0; i < iterations; i++ {
NewTree(contents)
}
}
func BenchmarkNewTreeCC2(b *testing.B) {
for i := 0; i < iterations; i++ {
NewTreeCC(2, contents)
}
}
func BenchmarkNewTreeCC4(b *testing.B) {
for i := 0; i < iterations; i++ {
NewTreeCC(4, contents)
}
}
func BenchmarkNewTreeCC8(b *testing.B) {
for i := 0; i < iterations; i++ {
NewTreeCC(8, contents)
}
}