add more benchmarks

This commit is contained in:
Zack Scholl 2021-04-21 12:40:41 -07:00
parent 94b3dba034
commit ab5ae5cbb6
2 changed files with 18 additions and 0 deletions

View File

@ -94,6 +94,15 @@ func IMOHashFile(fname string) (hash []byte, err error) {
return
}
var imofull = imohash.NewCustom(0, 0)
// IMOHashFileFull returns imohash of full file
func IMOHashFileFull(fname string) (hash []byte, err error) {
b, err := imofull.SumFile(fname)
hash = b[:]
return
}
// XXHashFile returns the xxhash of a file
func XXHashFile(fname string) (hash256 []byte, err error) {
f, err := os.Open(fname)

View File

@ -35,6 +35,7 @@ func BenchmarkXXHash(b *testing.B) {
XXHashFile("bigfile.test")
}
}
func BenchmarkImoHash(b *testing.B) {
bigFile()
b.ResetTimer()
@ -43,6 +44,14 @@ func BenchmarkImoHash(b *testing.B) {
}
}
func BenchmarkImoHashFull(b *testing.B) {
bigFile()
b.ResetTimer()
for i := 0; i < b.N; i++ {
IMOHashFileFull("bigfile.test")
}
}
func BenchmarkSha256(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {