Exemple #1
0
func testBloomFilter(t *testing.T, bf bloom.Bloom) {
	fn, fp := 0, 0

	for l := range web2 {
		if !(bf.Add([]byte(web2[l])).Check([]byte(web2[l]))) {
			fn++
		}
	}

	bf.PrintStats()

	for l := range web2a {
		if bf.Check([]byte(web2a[l])) {
			//fmt.Println("False Positive:", web2a[l])
			fp++
		}
	}

	fmt.Printf("Total false negatives: %d (%.4f%%)\n", fn, (float32(fn) / float32(len(web2)) * 100))
	fmt.Printf("Total false positives: %d (%.4f%%)\n", fp, (float32(fp) / float32(len(web2a)) * 100))
}