From bec1410d5641fa37fd5cc4d017f984ba4efa150f Mon Sep 17 00:00:00 2001 From: Mohsen Azimi Date: Wed, 29 Jan 2025 15:38:53 +0700 Subject: [PATCH] bench: fix single small file benchmark --- benches/serialization.rs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/benches/serialization.rs b/benches/serialization.rs index c4c1997..757b439 100644 --- a/benches/serialization.rs +++ b/benches/serialization.rs @@ -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(); }