Skip to content

Commit

Permalink
array_subset_indices_iterator benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
LDeakin committed Nov 9, 2023
1 parent c03ea22 commit cf3485c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ chrono = "0.4"
criterion = "0.5.1"
tempfile = "3"

[[bench]]
name = "array_subset"
harness = false

[[bench]]
name = "array_uncompressed"
harness = false
Expand Down
26 changes: 26 additions & 0 deletions benches/array_subset.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use criterion::{
black_box, criterion_group, criterion_main, AxisScale, BenchmarkId, Criterion,
PlotConfiguration, Throughput,
};
use zarrs::array_subset::ArraySubset;

fn array_subset_indices_iterator(c: &mut Criterion) {
let plot_config = PlotConfiguration::default().summary_scale(AxisScale::Logarithmic);
let mut group = c.benchmark_group(format!("array_subset_indices_iterator"));
group.plot_config(plot_config);

for array_subset_size in [4, 16, 64, 256] {
let array_subset = ArraySubset::new_with_shape(vec![array_subset_size; 3]);
group.throughput(Throughput::Elements(array_subset.num_elements()));
group.bench_function(BenchmarkId::new("size", array_subset_size), |b| {
b.iter(|| {
array_subset.iter_indices().for_each(|indices| {
black_box(indices.first().unwrap());
})
});
});
}
}

criterion_group!(benches, array_subset_indices_iterator);
criterion_main!(benches);

0 comments on commit cf3485c

Please sign in to comment.