-
Notifications
You must be signed in to change notification settings - Fork 35
/
bench_test.go
58 lines (45 loc) · 948 Bytes
/
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
54
55
56
57
58
// SPDX-FileCopyrightText: 2015-2024 caixw
//
// SPDX-License-Identifier: MIT
package identicon
import (
"math/rand"
"testing"
"time"
"github.com/issue9/assert/v4"
)
func BenchmarkMake(b *testing.B) {
a := assert.New(b, false)
for i := 0; i < b.N; i++ {
img := Make(Style1, size, back, fore, []byte("Make"))
a.NotNil(img)
}
}
func BenchmarkIdenticon_Make_v1(b *testing.B) {
a := assert.New(b, false)
ii := S1(size)
a.NotNil(ii)
for i := 0; i < b.N; i++ {
img := ii.Make([]byte("Make"))
a.NotNil(img)
}
}
func BenchmarkIdenticon_Rand_v2(b *testing.B) {
a := assert.New(b, false)
r := rand.New(rand.NewSource(time.Now().Unix()))
ii := S1(size)
a.NotNil(ii)
for i := 0; i < b.N; i++ {
img := ii.Rand(r)
a.NotNil(img)
}
}
func BenchmarkIdenticon_Make_v2(b *testing.B) {
a := assert.New(b, false)
ii := S2(size)
a.NotNil(ii)
for i := 0; i < b.N; i++ {
img := ii.Make([]byte("Make"))
a.NotNil(img)
}
}