Skip to content

Commit

Permalink
Extra post-op stats (#73)
Browse files Browse the repository at this point in the history
Include info about number of files compressed/decompressed in stats

Related to #69
  • Loading branch information
Dr-Emann authored Jun 25, 2024
1 parent bb7c86c commit da8dc01
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions crates/applesauce-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,10 @@ fn main() {
verify,
);
progress_bars.finish();
drop(progress_bars);
tracing::info!("Finished compressing");
if verbosity >= Verbosity::Normal {
display_stats(&stats);
display_stats(&stats, true);
}
}
Commands::Decompress(Decompress {
Expand All @@ -272,7 +273,7 @@ fn main() {
progress_bars.finish();
tracing::info!("Finished decompressing");
if verbosity >= Verbosity::Normal {
display_stats(&stats);
display_stats(&stats, false);
}
}
Commands::Info(info) => {
Expand Down Expand Up @@ -369,9 +370,30 @@ fn main() {
}
}

pub fn display_stats(stats: &Stats) {
pub fn display_stats(stats: &Stats, compress_mode: bool) {
println!("Total Files: {}", stats.files.load(Ordering::Relaxed));
let total_file_sizes = stats.total_file_sizes.load(Ordering::Relaxed);

let compressed_count_start = stats.compressed_file_count_start.load(Ordering::Relaxed);
let compressed_count_final = stats.compressed_file_count_final.load(Ordering::Relaxed);
if compress_mode {
println!(
"New Files Compressed: {} ({} total compressed)",
compressed_count_final.saturating_sub(compressed_count_start),
compressed_count_final,
);
} else {
print!(
"Files Decompressed: {}",
compressed_count_start.saturating_sub(compressed_count_final),
);
if compressed_count_final != 0 {
println!(" ({} remaining compressed)", compressed_count_final);
} else {
println!();
}
}

let compressed_size_start = stats.compressed_size_start.load(Ordering::Relaxed);
let compressed_size_final = stats.compressed_size_final.load(Ordering::Relaxed);
println!(
Expand Down

0 comments on commit da8dc01

Please sign in to comment.