Skip to content

Commit

Permalink
bench: fix single small file benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsen1 committed Jan 29, 2025
1 parent c44ff28 commit bec1410
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions benches/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,29 @@ fn create_multiple_token_files(dir: &Path, tokens: &[usize], prefix: &str) {

fn bench_single_small_file(c: &mut Criterion) {
let mut group = c.benchmark_group("SingleFile_ByteMode");
group.measurement_time(Duration::from_secs(10));
group.sample_size(10);
let temp_dir = TempDir::new().unwrap();
create_test_data_bytes(temp_dir.path(), 10 * 1024, "small_file.txt"); // 10 KB

group.throughput(Throughput::Bytes((10 * 1024) as u64));
group.bench_function("single_small_file", |b| {
b.iter(|| {
let config = FullYekConfig::extend_config_with_defaults(
vec![temp_dir.path().to_string_lossy().to_string()],
temp_dir.path().to_string_lossy().to_string(),
);

serialize_repo(&config).unwrap();
});
b.iter_batched(
|| {
let output_dir = temp_dir.path().join("output");
fs::create_dir_all(&output_dir).unwrap();
output_dir
},
|output_dir| {
let config = FullYekConfig::extend_config_with_defaults(
vec![temp_dir.path().to_string_lossy().to_string()],
output_dir.to_string_lossy().to_string(),
);
serialize_repo(&config).unwrap();
fs::remove_dir_all(&output_dir).ok();
},
BatchSize::SmallInput,
);
});
group.finish();
}
Expand Down

0 comments on commit bec1410

Please sign in to comment.