1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// extern crate cuckoofilter;
// #[cfg(feature = "farmhash")]
// extern crate farmhash;
// #[cfg(feature = "fnv")]
// extern crate fnv;
// extern crate rand;
// use self::cuckoofilter::*;
// use std::error::Error;
// use std::fs::File;
// use std::io::prelude::*;
// use std::path::Path;
// fn get_words() -> String {
// let path = Path::new("/usr/share/dict/words");
// let display = path.display();
// // Open the path in read-only mode, returns `io::Result<File>`
// let mut file = match File::open(&path) {
// // The `description` method of `io::Error` returns a string that
// // describes the error
// Err(why) => panic!("couldn't open {}: {}", display, Error::description(&why)),
// Ok(file) => file,
// };
// let mut contents = String::new();
// if let Err(why) = file.read_to_string(&mut contents) {
// panic!("couldn't read {}: {}", display, Error::description(&why));
// }
// contents
// }
// fn perform_insertions<H: std::hash::Hasher + Default>(b: &mut test::Bencher) {
// let contents = get_words();
// let split: Vec<&str> = contents.split("\n").take(1000).collect();
// let mut cf = CuckooFilter::<H>::with_capacity(split.len() * 2);
// b.iter(|| {
// for s in &split {
// test::black_box(cf.test_and_add(s).unwrap());
// }
// });
// }
// #[bench]
// fn bench_new(b: &mut test::Bencher) {
// b.iter(|| {
// test::black_box(CuckooFilter::new());
// });
// }
// #[bench]
// fn bench_clear(b: &mut test::Bencher) {
// let mut cf = test::black_box(CuckooFilter::new());
// b.iter(|| {
// test::black_box(cf.clear());
// });
// }
// #[cfg(feature = "farmhash")]
// #[bench]
// fn bench_insertion_farmhash(b: &mut test::Bencher) {
// perform_insertions::<farmhash::FarmHasher>(b);
// }
// #[cfg(feature = "fnv")]
// #[bench]
// fn bench_insertion_fnv(b: &mut test::Bencher) {
// perform_insertions::<fnv::FnvHasher>(b);
// }
// #[bench]
// fn bench_insertion_default(b: &mut test::Bencher) {
// perform_insertions::<std::collections::hash_map::DefaultHasher>(b);
// }