-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathguuid_z_bench_test.go
73 lines (62 loc) · 1.34 KB
/
guuid_z_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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Copyright 2019 gf Author(https://github.com/gogf/gf). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
// go test *.go -bench=".*" -benchmem
package guuid_test
import (
"testing"
"github.com/gogf/guuid"
)
func Benchmark_New(b *testing.B) {
for i := 0; i < b.N; i++ {
guuid.New().String()
}
}
func Benchmark_NewUUID(b *testing.B) {
for i := 0; i < b.N; i++ {
if u, err := guuid.NewUUID(); err != nil {
panic(err)
} else {
u.String()
}
}
}
func Benchmark_NewDCEGroup(b *testing.B) {
for i := 0; i < b.N; i++ {
if u, err := guuid.NewDCEGroup(); err != nil {
panic(err)
} else {
u.String()
}
}
}
func Benchmark_NewDCEPerson(b *testing.B) {
for i := 0; i < b.N; i++ {
if u, err := guuid.NewDCEPerson(); err != nil {
panic(err)
} else {
u.String()
}
}
}
func Benchmark_NewRandom(b *testing.B) {
for i := 0; i < b.N; i++ {
if u, err := guuid.NewRandom(); err != nil {
panic(err)
} else {
u.String()
}
}
}
func Benchmark_NewMD5(b *testing.B) {
for i := 0; i < b.N; i++ {
guuid.NewMD5(guuid.UUID{}, []byte("")).String()
}
}
func Benchmark_NewSHA1(b *testing.B) {
for i := 0; i < b.N; i++ {
guuid.NewSHA1(guuid.UUID{}, []byte("")).String()
}
}