-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bab04ef
commit ce5ca44
Showing
4 changed files
with
1,014 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
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 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 BenchmarkUrlParseWithFragment(b *testing.B) { | ||
var u *url.URL | ||
for n := 0; n < b.N; n++ { | ||
u, _ = url.Parse("http://amzbjdl8etgpgwoe841sfi6fc4q9yh82.com#6pkmkw5pteabvtzm7p6qe106ysiawm") | ||
} | ||
parsedURL = u | ||
} |
Oops, something went wrong.