Add a HashName benchmark
This commit is contained in:
parent
1afd10068a
commit
2f8cf50b32
|
@ -1,6 +1,9 @@
|
||||||
package dns
|
package dns
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"strconv"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
func TestPackNsec3(t *testing.T) {
|
func TestPackNsec3(t *testing.T) {
|
||||||
nsec3 := HashName("dnsex.nl.", SHA1, 0, "DEAD")
|
nsec3 := HashName("dnsex.nl.", SHA1, 0, "DEAD")
|
||||||
|
@ -151,3 +154,17 @@ func TestNsec3EmptySalt(t *testing.T) {
|
||||||
t.Fatalf("expected record to match com. label")
|
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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue