Skip to content

Commit

Permalink
perf: benchmark chunk file from file storage vs object storage
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Dec 20, 2023
1 parent 2a8732e commit 5e63393
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions subfile-exchange/benches/new_chunk_file.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
use criterion::async_executor::FuturesExecutor;
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use subfile_exchange::{subfile::ChunkFile, test_util::CHUNK_SIZE};

fn new_chunk_file_benchmark(c: &mut Criterion) {
use subfile_exchange::{
subfile::{local_file_system::Store, ChunkFile},
test_util::CHUNK_SIZE,
};
fn new_chunk_file_benchmark_file_store(c: &mut Criterion) {
// ChunkFile::new(&self.config.read_dir, file_name, self.config.chunk_size)
let read_dir = black_box("../example-file");
let file_name = black_box("0017234600.dbin.zst");
let file_size = black_box(CHUNK_SIZE);

c.bench_function("new_chunk_file", |b| {
c.bench_function("new_chunk_file_benchmark_file_store", |b| {
b.iter(|| ChunkFile::new(read_dir, file_name, file_size).unwrap())
});
}

criterion_group!(benches, new_chunk_file_benchmark);
fn new_chunk_file_benchmark_object_store(c: &mut Criterion) {
let store = black_box(Store::new("../example-file").unwrap());
let file_name = black_box("0017234600.dbin.zst");
let file_size = black_box(Some(CHUNK_SIZE as usize));

c.bench_function("new_chunk_file_benchmark_object_store", |b| {
b.to_async(FuturesExecutor)
.iter(|| store.chunk_file(file_name, file_size))
});
}

criterion_group!(
benches,
new_chunk_file_benchmark_file_store,
new_chunk_file_benchmark_object_store
);
criterion_main!(benches);

0 comments on commit 5e63393

Please sign in to comment.