mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 18:37:45 +08:00
Merge pull request #1154 from ipfs/feat/bench-hash
add a benchmark for our hash function
This commit is contained in:
commit
d047fe4fcb
@ -53,3 +53,33 @@ func TestXOR(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkHash256K(b *testing.B) {
|
||||
buf := make([]byte, 256*1024)
|
||||
NewTimeSeededRand().Read(buf)
|
||||
b.SetBytes(int64(256 * 1024))
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
Hash(buf)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkHash512K(b *testing.B) {
|
||||
buf := make([]byte, 512*1024)
|
||||
NewTimeSeededRand().Read(buf)
|
||||
b.SetBytes(int64(512 * 1024))
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
Hash(buf)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkHash1M(b *testing.B) {
|
||||
buf := make([]byte, 1024*1024)
|
||||
NewTimeSeededRand().Read(buf)
|
||||
b.SetBytes(int64(1024 * 1024))
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
Hash(buf)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user