2023-07-23 11:40:22 +02:00

36 lines
628 B
Go

package hash_test
import (
"bytes"
"testing"
"git.akyoto.dev/go/hash"
)
func BenchmarkSize(b *testing.B) {
b.Run("7", bench(7))
b.Run("8", bench(8))
b.Run("16", bench(16))
b.Run("17", bench(17))
b.Run("32", bench(32))
b.Run("33", bench(33))
b.Run("64", bench(64))
b.Run("65", bench(65))
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)
for i := 0; i < b.N; i++ {
hash.Bytes(tmp)
}
}
}