alpha
Login
or
Join now
urschrei.eurosky.social
/
cvmcount
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Rust implementation of the CVM algorithm for counting distinct elements in a stream
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
Add HashSet benchmark for comparison
author
Stephan Hügel
date
2 years ago
(May 29, 2024, 11:53 AM +0100)
commit
aca6e11d
aca6e11d0db21cf73b07b050d23d71dd73815353
parent
4b382d6b
4b382d6b4b38cfd74f1f4f57e7aa8571061e7d7d
+19
-2
1 changed file
Expand all
Collapse all
Unified
Split
benches
benchmarks.rs
+19
-2
benches/benchmarks.rs
Reviewed
···
11
11
use rand::{thread_rng, Rng};
12
12
use regex::Regex;
13
13
14
14
+
use rustc_hash::FxHashSet;
15
15
+
14
16
// generate 1 million 7-digit random positive integers
15
17
fn generate_random_numbers() -> Vec<i32> {
16
18
let mut rng = thread_rng();
···
64
66
let digits = generate_random_numbers();
65
67
b.iter(|| {
66
68
let mut int_counter: CVM<i32> = CVM::new(epsilon, delta, stream_size);
67
67
-
digits.iter().for_each(|integer| int_counter.process_element(*integer));
69
69
+
digits
70
70
+
.iter()
71
71
+
.for_each(|integer| int_counter.process_element(*integer));
68
72
int_counter.calculate_final_result()
69
73
})
70
70
-
}
74
74
+
},
75
75
+
);
76
76
+
c.bench_function(
77
77
+
"Count uniques in ten million 7-digit random positive integers: HashSet",
78
78
+
|b| {
79
79
+
let digits = generate_random_numbers();
80
80
+
b.iter(|| {
81
81
+
let mut hs = FxHashSet::with_hasher(Default::default());
82
82
+
digits.iter().for_each(|digit| {
83
83
+
hs.insert(digit);
84
84
+
});
85
85
+
digits.len()
86
86
+
})
87
87
+
},
71
88
);
72
89
}
73
90