-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmarks_test.go
53 lines (48 loc) · 1003 Bytes
/
benchmarks_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 stun
import (
"testing"
)
func BenchmarkParseMessageFingerprint(b *testing.B) {
bb := New(TypeBindingRequest, txID)
bb.AddFingerprint()
raw, err := bb.Build()
if err != nil {
b.Fatalf("build failed: %v", err)
}
var m Message
var p Parser
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = p.Parse(&m, raw)
}
}
func BenchmarkParseMessageIntegrity(b *testing.B) {
bb := New(TypeBindingRequest, txID)
bb.SetPassword(testPassword)
bb.AddMessageIntegrity()
raw, err := bb.Build()
if err != nil {
b.Fatalf("build failed: %v", err)
}
var p Parser
var m Message
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = p.Parse(&m, raw)
}
}
func BenchmarkParseMessageIntegritySHA256(b *testing.B) {
bb := New(TypeBindingRequest, txID)
bb.SetPassword(testPassword)
bb.AddMessageIntegritySHA256()
raw, err := bb.Build()
if err != nil {
b.Fatalf("build failed: %v", err)
}
var p Parser
var m Message
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = p.Parse(&m, raw)
}
}