github.com/segmentio/parquet-go@v0.0.0-20230712180008-5d42db8f0d47/bloom/bloom_test.go (about) 1 package bloom 2 3 import ( 4 "math/rand" 5 "testing" 6 ) 7 8 // Test file for internal functions of the bloom package. 9 var global4x64 [4]uint64 10 11 func TestFasthash(t *testing.T) { 12 r := rand.NewSource(0).(rand.Source64) 13 14 src := [4]uint64{r.Uint64(), r.Uint64(), r.Uint64(), r.Uint64()} 15 dst := [4]uint64{0, 0, 0, 0} 16 exp := [4]uint64{483, 125, 335, 539} 17 mod := int32(1024) 18 19 fasthash4x64(&dst, &src, mod) 20 21 if dst != exp { 22 t.Errorf("got=%v want=%v", dst, exp) 23 } 24 } 25 26 func BenchmarkFasthash(b *testing.B) { 27 src := [4]uint64{} 28 dst := [4]uint64{} 29 mod := int32(1024) 30 31 for i := 0; i < b.N; i++ { 32 fasthash4x64(&dst, &src, mod) 33 } 34 35 b.SetBytes(32) 36 global4x64 = dst // use it so the loop isn't optimized away 37 }