Skip to content

Commit

Permalink
Add a HashName benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
tmthrgd committed Nov 28, 2018
1 parent 1afd100 commit 2f8cf50
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion nsecx_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package dns

import "testing"
import (
"strconv"
"testing"
)

func TestPackNsec3(t *testing.T) {
nsec3 := HashName("dnsex.nl.", SHA1, 0, "DEAD")
Expand Down Expand Up @@ -151,3 +154,17 @@ func TestNsec3EmptySalt(t *testing.T) {
t.Fatalf("expected record to match com. label")
}
}

func BenchmarkHashName(b *testing.B) {
for _, iter := range []uint16{
150, 2500, 5000, 10000, ^uint16(0),
} {
b.Run(strconv.Itoa(int(iter)), func(b *testing.B) {
for n := 0; n < b.N; n++ {
if HashName("some.example.org.", SHA1, iter, "deadbeef") == "" {
b.Fatalf("HashName failed")
}
}
})
}
}

0 comments on commit 2f8cf50

Please sign in to comment.