| 64 | } |
| 65 | |
| 66 | fn benchmark_lookup(total_elements: usize) -> (std::time::Duration, usize) { |
| 67 | let static_random = 0x12345678; |
| 68 | let mut fixed_set = PerformantFixedSet::new(static_random); |
| 69 | |
| 70 | // Populate the set |
| 71 | for i in 0..total_elements { |
| 72 | fixed_set.insert(i as u32); |
| 73 | } |
| 74 | |
| 75 | // Benchmark lookups |
| 76 | let start = Instant::now(); |
| 77 | let lookups = (0..total_elements) |
| 78 | .filter(|&i| fixed_set.is_member(i as u32)) |
| 79 | .count(); |
| 80 | let duration = start.elapsed(); |
| 81 | |
| 82 | (duration, lookups) |
| 83 | } |
| 84 | |
| 85 | fn benchmark_hashset_lookup(total_elements: usize) -> (std::time::Duration, usize) { |
| 86 | let mut hash_set = HashSet::new(); |