-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: benchmark chunk file from file storage vs object storage
- Loading branch information
Showing
1 changed file
with
23 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |