1
0
mirror of https://github.com/schollz/croc.git synced 2024-11-24 08:02:33 +03:00

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 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 // XXHashFile returns the xxhash of a file
func XXHashFile(fname string) (hash256 []byte, err error) { func XXHashFile(fname string) (hash256 []byte, err error) {
f, err := os.Open(fname) f, err := os.Open(fname)

View File

@ -35,6 +35,7 @@ func BenchmarkXXHash(b *testing.B) {
XXHashFile("bigfile.test") XXHashFile("bigfile.test")
} }
} }
func BenchmarkImoHash(b *testing.B) { func BenchmarkImoHash(b *testing.B) {
bigFile() bigFile()
b.ResetTimer() 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) { func BenchmarkSha256(b *testing.B) {
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {