aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2019-01-16 01:14:35 +0100
committerDimitri Sokolyuk <demon@dim13.org>2019-01-16 01:14:35 +0100
commit389f7e907adb4d0723c6d609e00e4522ceef714d (patch)
tree62052b6550822ae65cbd981a9da378feb2514bc5
parent65f780cdcff14da4c3214fe9ed597c3f8629c923 (diff)
extend benchmarks
-rw-r--r--internal/hash/hash_func_test.go14
-rw-r--r--internal/hash/hash_log2_test.go9
2 files changed, 18 insertions, 5 deletions
diff --git a/internal/hash/hash_func_test.go b/internal/hash/hash_func_test.go
index 15919c3..a021ad8 100644
--- a/internal/hash/hash_func_test.go
+++ b/internal/hash/hash_func_test.go
@@ -28,8 +28,16 @@ func TestDefaultHash(t *testing.T) {
}
func BenchmarkDefaultHash(b *testing.B) {
- key := []byte("THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG")
- for i := 0; i < b.N; i++ {
- defaultHash(key)
+ benchCases := []string{
+ "A",
+ "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG",
+ }
+ for _, bc := range benchCases {
+ b.Run(bc, func(b *testing.B) {
+ key := []byte(bc)
+ for i := 0; i < b.N; i++ {
+ defaultHash(key)
+ }
+ })
}
}
diff --git a/internal/hash/hash_log2_test.go b/internal/hash/hash_log2_test.go
index f4c8bf3..869edba 100644
--- a/internal/hash/hash_log2_test.go
+++ b/internal/hash/hash_log2_test.go
@@ -31,7 +31,12 @@ func TestLog2(t *testing.T) {
}
func BenchmarkLog2(b *testing.B) {
- for i := 0; i < b.N; i++ {
- log2(1024)
+ benchCases := []uint32{1, 1024}
+ for _, bc := range benchCases {
+ b.Run(fmt.Sprintf("log(%v)", bc), func(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ log2(1024)
+ }
+ })
}
}