Skip to content

Commit 61b0cb1

Browse files
Dandandanalamb
authored andcommitted
ARROW-11358: [Rust] Add benchmark for concatenating small arrays
This is a common usecase in DataFusion, for coalescing & hash aggregates. Closes #9302 from Dandandan/concat_perf Authored-by: Heres, Daniel <[email protected]> Signed-off-by: Andrew Lamb <[email protected]>
1 parent 4a9885e commit 61b0cb1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

rust/arrow/benches/concatenate_kernel.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ fn bench_concat(v1: &ArrayRef, v2: &ArrayRef) {
7676
criterion::black_box(concat(&[v1.as_ref(), v2.as_ref()]).unwrap());
7777
}
7878

79+
fn bench_concat_arrays(arrays: &[&dyn Array]) {
80+
criterion::black_box(concat(arrays).unwrap());
81+
}
82+
7983
fn add_benchmark(c: &mut Criterion) {
8084
let v1 = create_primitive::<Int32Type>(1024, 0.0);
8185
let v2 = create_primitive::<Int32Type>(1024, 0.0);
@@ -87,6 +91,12 @@ fn add_benchmark(c: &mut Criterion) {
8791
b.iter(|| bench_concat(&v1, &v2))
8892
});
8993

94+
let small_array = create_primitive::<Int32Type>(4, 0.0);
95+
let arrays: Vec<_> = (0..1024).map(|_| small_array.as_ref()).collect();
96+
c.bench_function("concat 1024 arrays i32 4", |b| {
97+
b.iter(|| bench_concat_arrays(&arrays))
98+
});
99+
90100
let v1 = create_strings(1024, 0.0);
91101
let v2 = create_strings(1024, 0.0);
92102
c.bench_function("concat str 1024", |b| b.iter(|| bench_concat(&v1, &v2)));

0 commit comments

Comments
 (0)