MCPcopy Create free account
hub / github.com/cosdata/cosdata / benchmark_lookup

Function benchmark_lookup

org/src/performant_fixed_set.rs:66–83  ·  view source on GitHub ↗
(total_elements: usize)

Source from the content-addressed store, hash-verified

64}
65
66fn 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
85fn benchmark_hashset_lookup(total_elements: usize) -> (std::time::Duration, usize) {
86 let mut hash_set = HashSet::new();

Callers 1

mainFunction · 0.85

Calls 2

insertMethod · 0.45
is_memberMethod · 0.45

Tested by

no test coverage detected