- Implemented multi-threaded directory traversal using ignore::WalkParallel - Added dynamic thread allocation for balanced CPU utilization - Refactored core logic to single-pass, in-memory tree construction (O(N)) - Added --compare, --units, and --precision flags - Established SCM-neutral distribution pipeline (Makefile, release.sh, Homebrew) - Comprehensive updates to README.md, MANUAL.md, and CHANGELOG.md - Decoupled from SCM-specific workflows
35 lines
1.0 KiB
Rust
35 lines
1.0 KiB
Rust
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
|
use sized::build_tree;
|
|
use std::fs::{self, File};
|
|
use std::io::Write;
|
|
use tempfile::TempDir; // Ensure this is pub in lib.rs
|
|
|
|
fn setup_test_dir() -> TempDir {
|
|
let temp_dir = TempDir::new().unwrap();
|
|
let base_path = temp_dir.path();
|
|
|
|
// Create a moderately deep structure
|
|
for i in 0..10 {
|
|
let dir_path = base_path.join(format!("dir_{}", i));
|
|
fs::create_dir(&dir_path).unwrap();
|
|
for j in 0..10 {
|
|
let file_path = dir_path.join(format!("file_{}.txt", j));
|
|
let mut file = File::create(file_path).unwrap();
|
|
writeln!(file, "Some content for file {}-{}", i, j).unwrap();
|
|
}
|
|
}
|
|
temp_dir
|
|
}
|
|
|
|
fn criterion_benchmark(c: &mut Criterion) {
|
|
let temp_dir = setup_test_dir();
|
|
let path = temp_dir.path();
|
|
|
|
c.bench_function("build_tree small", |b| {
|
|
b.iter(|| build_tree(black_box(path), black_box(false), black_box(false)))
|
|
});
|
|
}
|
|
|
|
criterion_group!(benches, criterion_benchmark);
|
|
criterion_main!(benches);
|