32 lines
534 B
Go
Raw Normal View History

2023-07-22 15:02:22 +00:00
package hash_test
import (
2023-07-22 22:46:39 +00:00
"bytes"
2023-07-22 15:02:22 +00:00
"testing"
"git.akyoto.dev/go/hash"
)
2023-07-22 22:46:39 +00:00
func BenchmarkSize(b *testing.B) {
b.Run("8", bench(8))
b.Run("16", bench(16))
b.Run("32", bench(32))
b.Run("64", bench(64))
b.Run("128", bench(128))
b.Run("256", bench(256))
b.Run("512", bench(512))
b.Run("1024", bench(1024))
b.Run("2048", bench(2048))
b.Run("4096", bench(4096))
}
func bench(n int) func(*testing.B) {
return func(b *testing.B) {
tmp := bytes.Repeat([]byte{'a'}, n)
2023-07-22 15:02:22 +00:00
2023-07-22 22:46:39 +00:00
for i := 0; i < b.N; i++ {
hash.Bytes(tmp)
}
2023-07-22 15:02:22 +00:00
}
}