diff options
Diffstat (limited to 'tinyufo/benches/bench_memory.rs')
-rw-r--r-- | tinyufo/benches/bench_memory.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tinyufo/benches/bench_memory.rs b/tinyufo/benches/bench_memory.rs index 9d49210..271fe12 100644 --- a/tinyufo/benches/bench_memory.rs +++ b/tinyufo/benches/bench_memory.rs @@ -52,6 +52,22 @@ fn bench_moka(zip_exp: f64, items: usize, cache_size_percent: f32) { } } +fn bench_quick_cache(zip_exp: f64, items: usize, cache_size_percent: f32) { + let cache_size = (cache_size_percent * items as f32).round() as usize; + let quick_cache = quick_cache::sync::Cache::new(cache_size); + + let mut rng = thread_rng(); + let zipf = zipf::ZipfDistribution::new(items, zip_exp).unwrap(); + + for _ in 0..ITERATIONS { + let key = zipf.sample(&mut rng) as u64; + + if quick_cache.get(&key).is_none() { + quick_cache.insert(key, ()); + } + } +} + fn bench_tinyufo(zip_exp: f64, items: usize, cache_size_percent: f32) { let cache_size = (cache_size_percent * items as f32).round() as usize; let tinyufo = tinyufo::TinyUfo::new(cache_size, (cache_size as f32 * 1.0) as usize); @@ -92,6 +108,8 @@ lru dhat: At t-gmax: 9,408 bytes in 106 blocks moka dhat: At t-gmax: 354,232 bytes in 1,581 blocks +QuickCache +dhat: At t-gmax: 11,840 bytes in 8 blocks TinyUFO dhat: At t-gmax: 37,337 bytes in 351 blocks TinyUFO compat @@ -102,6 +120,8 @@ lru dhat: At t-gmax: 128,512 bytes in 1,004 blocks moka dhat: At t-gmax: 535,320 bytes in 7,278 blocks +QuickCache +dhat: At t-gmax: 93,000 bytes in 66 blocks TinyUFO dhat: At t-gmax: 236,053 bytes in 2,182 blocks TinyUFO Compact @@ -112,6 +132,8 @@ lru dhat: At t-gmax: 1,075,648 bytes in 10,004 blocks moka dhat: At t-gmax: 2,489,088 bytes in 62,374 blocks +QuickCache +dhat: At t-gmax: 863,752 bytes in 66 blocks TinyUFO dhat: At t-gmax: 2,290,635 bytes in 20,467 blocks TinyUFO @@ -135,6 +157,12 @@ fn main() { { let _profiler = dhat::Profiler::new_heap(); + bench_quick_cache(1.05, items, 0.1); + println!("\nQuickCache"); + } + + { + let _profiler = dhat::Profiler::new_heap(); bench_tinyufo(1.05, items, 0.1); println!("\nTinyUFO"); } |