diff --git a/nsecx_test.go b/nsecx_test.go index 84329c9e..ee926533 100644 --- a/nsecx_test.go +++ b/nsecx_test.go @@ -1,6 +1,9 @@ package dns -import "testing" +import ( + "strconv" + "testing" +) func TestPackNsec3(t *testing.T) { nsec3 := HashName("dnsex.nl.", SHA1, 0, "DEAD") @@ -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") + } + } + }) + } +}