Skip to content

Commit 97b951e

Browse files
committed
Replace deprecated zipf with rand_distr
1 parent f8d0127 commit 97b951e

File tree

5 files changed

+37
-37
lines changed

5 files changed

+37
-37
lines changed

.bleep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e6597ea67a5a6c4fcdd79d63de1e3d04a46d7a35
1+
d698dfe945ece23e1fda528ade4ca3931951169b

tinyufo/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ crossbeam-queue = "0"
2222
crossbeam-skiplist = "0"
2323

2424
[dev-dependencies]
25-
rand = "0.8"
25+
rand = "0.9"
2626
lru = "0"
27-
zipf = "7"
27+
rand_distr = "0.5"
2828
moka = { version = "0", features = ["sync"] }
2929
dhat = "0"
3030
quick_cache = "0.6"

tinyufo/benches/bench_hit_ratio.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ fn bench_one(zip_exp: f64, cache_size_percent: f32) {
2626
let quick_cache = quick_cache::sync::Cache::new(cache_size);
2727
let tinyufo = tinyufo::TinyUfo::new(cache_size, cache_size);
2828

29-
let mut rng = thread_rng();
30-
let zipf = zipf::ZipfDistribution::new(ITEMS, zip_exp).unwrap();
29+
let mut rng = rand::rng();
30+
let zipf = rand_distr::Zipf::new(ITEMS as f64, zip_exp).unwrap();
3131

3232
let mut lru_hit = 0;
3333
let mut moka_hit = 0;

tinyufo/benches/bench_memory.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ fn bench_lru(zip_exp: f64, items: usize, cache_size_percent: f32) {
2424
let cache_size = (cache_size_percent * items as f32).round() as usize;
2525
let mut lru = lru::LruCache::<u64, ()>::new(NonZeroUsize::new(cache_size).unwrap());
2626

27-
let mut rng = thread_rng();
28-
let zipf = zipf::ZipfDistribution::new(items, zip_exp).unwrap();
27+
let mut rng = rand::rng();
28+
let zipf = rand_distr::Zipf::new(items as f64, zip_exp).unwrap();
2929

3030
for _ in 0..ITERATIONS {
3131
let key = zipf.sample(&mut rng) as u64;
@@ -40,8 +40,8 @@ fn bench_moka(zip_exp: f64, items: usize, cache_size_percent: f32) {
4040
let cache_size = (cache_size_percent * items as f32).round() as usize;
4141
let moka = moka::sync::Cache::new(cache_size as u64);
4242

43-
let mut rng = thread_rng();
44-
let zipf = zipf::ZipfDistribution::new(items, zip_exp).unwrap();
43+
let mut rng = rand::rng();
44+
let zipf = rand_distr::Zipf::new(items as f64, zip_exp).unwrap();
4545

4646
for _ in 0..ITERATIONS {
4747
let key = zipf.sample(&mut rng) as u64;
@@ -56,8 +56,8 @@ fn bench_quick_cache(zip_exp: f64, items: usize, cache_size_percent: f32) {
5656
let cache_size = (cache_size_percent * items as f32).round() as usize;
5757
let quick_cache = quick_cache::sync::Cache::new(cache_size);
5858

59-
let mut rng = thread_rng();
60-
let zipf = zipf::ZipfDistribution::new(items, zip_exp).unwrap();
59+
let mut rng = rand::rng();
60+
let zipf = rand_distr::Zipf::new(items as f64, zip_exp).unwrap();
6161

6262
for _ in 0..ITERATIONS {
6363
let key = zipf.sample(&mut rng) as u64;
@@ -72,8 +72,8 @@ fn bench_tinyufo(zip_exp: f64, items: usize, cache_size_percent: f32) {
7272
let cache_size = (cache_size_percent * items as f32).round() as usize;
7373
let tinyufo = tinyufo::TinyUfo::new(cache_size, (cache_size as f32 * 1.0) as usize);
7474

75-
let mut rng = thread_rng();
76-
let zipf = zipf::ZipfDistribution::new(items, zip_exp).unwrap();
75+
let mut rng = rand::rng();
76+
let zipf = rand_distr::Zipf::new(items as f64, zip_exp).unwrap();
7777

7878
for _ in 0..ITERATIONS {
7979
let key = zipf.sample(&mut rng) as u64;
@@ -88,8 +88,8 @@ fn bench_tinyufo_compact(zip_exp: f64, items: usize, cache_size_percent: f32) {
8888
let cache_size = (cache_size_percent * items as f32).round() as usize;
8989
let tinyufo = tinyufo::TinyUfo::new_compact(cache_size, (cache_size as f32 * 1.0) as usize);
9090

91-
let mut rng = thread_rng();
92-
let zipf = zipf::ZipfDistribution::new(items, zip_exp).unwrap();
91+
let mut rng = rand::rng();
92+
let zipf = rand_distr::Zipf::new(items as f64, zip_exp).unwrap();
9393

9494
for _ in 0..ITERATIONS {
9595
let key = zipf.sample(&mut rng) as u64;

tinyufo/benches/bench_perf.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ fn main() {
9595
}
9696

9797
// single thread
98-
let mut rng = thread_rng();
99-
let zipf = zipf::ZipfDistribution::new(ITEMS, 1.03).unwrap();
98+
let mut rng = rand::rng();
99+
let zipf = rand_distr::Zipf::new(ITEMS as f64, 1.03).unwrap();
100100

101101
let before = Instant::now();
102102
for _ in 0..ITERATIONS {
@@ -159,8 +159,8 @@ fn main() {
159159
thread::scope(|s| {
160160
for _ in 0..THREADS {
161161
s.spawn(|| {
162-
let mut rng = thread_rng();
163-
let zipf = zipf::ZipfDistribution::new(ITEMS, 1.03).unwrap();
162+
let mut rng = rand::rng();
163+
let zipf = rand_distr::Zipf::new(ITEMS as f64, 1.03).unwrap();
164164
wg.wait();
165165
let before = Instant::now();
166166
for _ in 0..ITERATIONS {
@@ -186,8 +186,8 @@ fn main() {
186186
thread::scope(|s| {
187187
for _ in 0..THREADS {
188188
s.spawn(|| {
189-
let mut rng = thread_rng();
190-
let zipf = zipf::ZipfDistribution::new(ITEMS, 1.03).unwrap();
189+
let mut rng = rand::rng();
190+
let zipf = rand_distr::Zipf::new(ITEMS as f64, 1.03).unwrap();
191191
wg.wait();
192192
let before = Instant::now();
193193
for _ in 0..ITERATIONS {
@@ -213,8 +213,8 @@ fn main() {
213213
thread::scope(|s| {
214214
for _ in 0..THREADS {
215215
s.spawn(|| {
216-
let mut rng = thread_rng();
217-
let zipf = zipf::ZipfDistribution::new(ITEMS, 1.03).unwrap();
216+
let mut rng = rand::rng();
217+
let zipf = rand_distr::Zipf::new(ITEMS as f64, 1.03).unwrap();
218218
wg.wait();
219219
let before = Instant::now();
220220
for _ in 0..ITERATIONS {
@@ -240,8 +240,8 @@ fn main() {
240240
thread::scope(|s| {
241241
for _ in 0..THREADS {
242242
s.spawn(|| {
243-
let mut rng = thread_rng();
244-
let zipf = zipf::ZipfDistribution::new(ITEMS, 1.03).unwrap();
243+
let mut rng = rand::rng();
244+
let zipf = rand_distr::Zipf::new(ITEMS as f64, 1.03).unwrap();
245245
wg.wait();
246246
let before = Instant::now();
247247
for _ in 0..ITERATIONS {
@@ -267,8 +267,8 @@ fn main() {
267267
thread::scope(|s| {
268268
for _ in 0..THREADS {
269269
s.spawn(|| {
270-
let mut rng = thread_rng();
271-
let zipf = zipf::ZipfDistribution::new(ITEMS, 1.03).unwrap();
270+
let mut rng = rand::rng();
271+
let zipf = rand_distr::Zipf::new(ITEMS as f64, 1.03).unwrap();
272272
wg.wait();
273273
let before = Instant::now();
274274
for _ in 0..ITERATIONS {
@@ -303,8 +303,8 @@ fn main() {
303303
for _ in 0..THREADS {
304304
s.spawn(|| {
305305
let mut miss_count = 0;
306-
let mut rng = thread_rng();
307-
let zipf = zipf::ZipfDistribution::new(items, ZIPF_EXP).unwrap();
306+
let mut rng = rand::rng();
307+
let zipf = rand_distr::Zipf::new(items as f64, ZIPF_EXP).unwrap();
308308
wg.wait();
309309
let before = Instant::now();
310310
for _ in 0..ITERATIONS {
@@ -337,8 +337,8 @@ fn main() {
337337
for _ in 0..THREADS {
338338
s.spawn(|| {
339339
let mut miss_count = 0;
340-
let mut rng = thread_rng();
341-
let zipf = zipf::ZipfDistribution::new(items, ZIPF_EXP).unwrap();
340+
let mut rng = rand::rng();
341+
let zipf = rand_distr::Zipf::new(items as f64, ZIPF_EXP).unwrap();
342342
wg.wait();
343343
let before = Instant::now();
344344
for _ in 0..ITERATIONS {
@@ -370,8 +370,8 @@ fn main() {
370370
for _ in 0..THREADS {
371371
s.spawn(|| {
372372
let mut miss_count = 0;
373-
let mut rng = thread_rng();
374-
let zipf = zipf::ZipfDistribution::new(items, ZIPF_EXP).unwrap();
373+
let mut rng = rand::rng();
374+
let zipf = rand_distr::Zipf::new(items as f64, ZIPF_EXP).unwrap();
375375
wg.wait();
376376
let before = Instant::now();
377377
for _ in 0..ITERATIONS {
@@ -403,8 +403,8 @@ fn main() {
403403
for _ in 0..THREADS {
404404
s.spawn(|| {
405405
let mut miss_count = 0;
406-
let mut rng = thread_rng();
407-
let zipf = zipf::ZipfDistribution::new(items, ZIPF_EXP).unwrap();
406+
let mut rng = rand::rng();
407+
let zipf = rand_distr::Zipf::new(items as f64, ZIPF_EXP).unwrap();
408408
wg.wait();
409409
let before = Instant::now();
410410
for _ in 0..ITERATIONS {
@@ -437,8 +437,8 @@ fn main() {
437437
for _ in 0..THREADS {
438438
s.spawn(|| {
439439
let mut miss_count = 0;
440-
let mut rng = thread_rng();
441-
let zipf = zipf::ZipfDistribution::new(items, ZIPF_EXP).unwrap();
440+
let mut rng = rand::rng();
441+
let zipf = rand_distr::Zipf::new(items as f64, ZIPF_EXP).unwrap();
442442
wg.wait();
443443
let before = Instant::now();
444444
for _ in 0..ITERATIONS {

0 commit comments

Comments
 (0)