Open
Description
This issue is intended for tracking performance related discussion and benchmarks for #14136. #14136 itself is for overall progress reports.
Useful cargo script to summarize number and size of files got checksum'd
#!/usr/bin/env cargo
---cargo
[dependencies]
walkdir = "2"
---
use std::collections::HashMap;
use std::ffi::OsStr;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let walker = walkdir::WalkDir::new("target/debug/deps")
.into_iter()
.filter_entry(|e| e.file_type().is_dir() || e.path().extension() == Some(OsStr::new("d")));
let mut map = HashMap::with_capacity(8192);
for entry in walker {
let entry = entry?;
if entry.file_type().is_dir() {
continue;
}
for line in BufReader::new(File::open(entry.path())?).lines() {
let line = line?;
let Some(rest) = line.strip_prefix("# checksum:") else {
continue;
};
let mut parts = rest.splitn(3, ' ');
let (_, size, path) = (parts.next(), parts.next().unwrap(), parts.next().unwrap());
let size: u64 = size.strip_prefix("file_len:").unwrap().parse()?;
if let Some(old_size) = map.insert(path.to_string(), size) {
assert_eq!(old_size, size, "size doesn't match for {path}: {old_size} vs {size}");
}
}
}
let mut stdout = std::io::stdout().lock();
writeln!(stdout, "number of files: {}", map.len())?;
writeln!(stdout, "total file size: {}", map.values().sum::<u64>())?;
Ok(())
}