Exemplo n.º 1
0
func BenchmarkBloomCityHash(b *testing.B) {
	var lines []string
	lines = append(lines, web2...)
	for len(lines) < b.N {
		lines = append(lines, web2...)
	}

	bf := New(uint(b.N))
	bf.SetHasher(cityhash.New64())
	fn := 0

	b.ResetTimer()

	for l := 0; l < b.N; l++ {
		if !(bf.Add([]byte(lines[l])).Check([]byte(lines[l]))) {
			fn++
		}
	}

	b.StopTimer()
}
Exemplo n.º 2
0
func TestBloomFilter(t *testing.T) {
	l := []uint{uint(len(web2)), 200000, 100000, 50000}
	h := []hash.Hash{fnv.New64(), crc64.New(crc64.MakeTable(crc64.ECMA)), murmur3.New64(), cityhash.New64(), md5.New(), sha1.New()}
	n := []string{"fnv.New64()", "crc64.New()", "murmur3.New64()", "cityhash.New64()", "md5.New()", "sha1.New()"}
	b := []func(uint) bloom.Bloom{standard.New, partitioned.New}
	bn := []string{"standard", "partitioned"}

	for i := range l {
		for j := range h {
			for k := range b {
				fmt.Printf("\n\nTesting %s with size %d using %s\n", n[j], l[i], bn[k])
				bf := New(l[i])
				bf.SetHasher(h[j])
				bf.(*ScalableBloom).SetBloomFilter(b[k])
				bf.Reset()
				testBloomFilter(t, bf)
			}
		}
	}
}
Exemplo n.º 3
0
func TestBloomFilter(t *testing.T) {
	l := []uint{uint(len(web2)), 200000, 100000, 50000}
	h := []hash.Hash{fnv.New64(), crc64.New(crc64.MakeTable(crc64.ECMA)), murmur3.New64(), cityhash.New64(), md5.New(), sha1.New()}
	n := []string{"fnv.New64()", "crc64.New()", "murmur3.New64()", "cityhash.New64()", "md5.New()", "sha1.New()"}

	for i := range l {
		for j := range h {
			fmt.Printf("\n\nTesting %s with size %d\n", n[j], l[i])
			bf := New(l[i])
			bf.SetHasher(h[j])
			testBloomFilter(t, bf)
		}
	}
}