Skip to content

Commit

Permalink
improved cache message
Browse files Browse the repository at this point in the history
- include entries and capacity
  • Loading branch information
jqnatividad committed Sep 1, 2023
1 parent 8cb03ab commit bda9520
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,18 @@ macro_rules! update_cache_info {

match $cache_instance.lock() {
Ok(cache) => {
if cache.cache_size() > 0 {
let size = cache.cache_size();
if size > 0 {
let hits = cache.cache_hits().unwrap_or_default();
let misses = cache.cache_misses().unwrap_or(1);
let hit_ratio = (hits as f64 / (hits + misses) as f64) * 100.0;
let capacity = cache.cache_capacity();
$progress.set_message(format!(
" of {} records. Cache hit ratio: {hit_ratio:.2}%",
" of {} records. Cache {:.2}% entries: {} capacity: {}.",
HumanCount($progress.length().unwrap()),
hit_ratio,
HumanCount(size as u64),
HumanCount(capacity.unwrap() as u64),
));
}
},
Expand Down

0 comments on commit bda9520

Please sign in to comment.