-
Notifications
You must be signed in to change notification settings - Fork 21
/
benchmark_test.go
78 lines (65 loc) · 1.82 KB
/
benchmark_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
74
75
76
77
78
package did_test
import (
"net/url"
"testing"
"github.com/ockam-network/did"
)
var parsed *did.DID
func BenchmarkParse(b *testing.B) {
var p *did.DID
for n := 0; n < b.N; n++ {
p, _ = did.Parse("did:ockam:amzbjdl8etgpgwoe841sfi6fc4q9yh82m6pkmkw5pteabvtzm7p6qe106ysiawmo")
}
parsed = p
}
func BenchmarkParseWithPath(b *testing.B) {
var p *did.DID
for n := 0; n < b.N; n++ {
p, _ = did.Parse("did:ockam:amzbjdl8etgpgwoe841sfi6fc4q9yh82/6pkmkw5pteabvtzm7p6qe106ysiawmo")
}
parsed = p
}
func BenchmarkParseWithQuery(b *testing.B) {
var p *did.DID
for n := 0; n < b.N; n++ {
p, _ = did.Parse("did:ockam:amzbjdl8etgpgwoe841sfi6fc4q9yh82?6pkmkw5pteabvtzm7p6qe106ysiawmo")
}
parsed = p
}
func BenchmarkParseWithFragment(b *testing.B) {
var p *did.DID
for n := 0; n < b.N; n++ {
p, _ = did.Parse("did:ockam:amzbjdl8etgpgwoe841sfi6fc4q9yh82#6pkmkw5pteabvtzm7p6qe106ysiawmo")
}
parsed = p
}
// Sanity check against Go's URL parsing to make sure we're in the same order of magnitude
var parsedURL *url.URL
func BenchmarkUrlParse(b *testing.B) {
var u *url.URL
for n := 0; n < b.N; n++ {
u, _ = url.Parse("http://amzbjdl8etgpgwoe841sfi6fc4q9yh82m6pkmkw5pteabvtzm7p6qe106ysiawm.com")
}
parsedURL = u
}
func BenchmarkUrlParseWithPath(b *testing.B) {
var u *url.URL
for n := 0; n < b.N; n++ {
u, _ = url.Parse("http://amzbjdl8etgpgwoe841sfi6fc4q9yh82.com/6pkmkw5pteabvtzm7p6qe106ysiawm")
}
parsedURL = u
}
func BenchmarkUrlParseWithQuery(b *testing.B) {
var u *url.URL
for n := 0; n < b.N; n++ {
u, _ = url.Parse("http://amzbjdl8etgpgwoe841sfi6fc4q9yh82.com?6pkmkw5pteabvtzm7p6qe106ysiawm")
}
parsedURL = u
}
func BenchmarkUrlParseWithFragment(b *testing.B) {
var u *url.URL
for n := 0; n < b.N; n++ {
u, _ = url.Parse("http://amzbjdl8etgpgwoe841sfi6fc4q9yh82.com#6pkmkw5pteabvtzm7p6qe106ysiawm")
}
parsedURL = u
}