Skip to content

Commit 4b6c382

Browse files
authored
Add slicing benchmarks for vortex-buffer (#8323)
## Summary Adds a basic benchmark for slicing, including an Arrow baseline. Hopefully building up to #8322, but I want a baseline first. Signed-off-by: Adam Gutglick <adam@spiraldb.com>
1 parent a038963 commit 4b6c382

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

vortex-buffer/benches/vortex_buffer.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,42 @@ fn push_n_vortex_buffer<T: PrimInt>(bencher: Bencher, length: usize) {
140140
});
141141
}
142142

143+
const SLICE_WINDOW: usize = 64;
144+
145+
#[divan::bench(args = &[65_536usize])]
146+
fn slice_tight_loop_vortex(bencher: Bencher, len: usize) {
147+
let buf = Buffer::<i32>::from_iter(
148+
(0..i32::try_from(len).vortex_expect("len fits into i32")).map(|i| i % i32::MAX),
149+
);
150+
bencher.bench(|| {
151+
let mut offset = 0;
152+
while offset + SLICE_WINDOW <= len {
153+
divan::black_box(buf.slice(offset..offset + SLICE_WINDOW));
154+
offset += SLICE_WINDOW;
155+
}
156+
});
157+
}
158+
159+
#[divan::bench(args = &[65_536usize])]
160+
fn slice_tight_loop_arrow(bencher: Bencher, len: usize) {
161+
let buf = ScalarBuffer::<i32>::from_iter(
162+
(0..i32::try_from(len).vortex_expect("len fits into i32")).map(|i| i % i32::MAX),
163+
);
164+
bencher.bench(|| {
165+
let mut offset = 0;
166+
while offset + SLICE_WINDOW <= len {
167+
divan::black_box(buf.slice(offset, SLICE_WINDOW));
168+
offset += SLICE_WINDOW;
169+
}
170+
});
171+
}
172+
173+
#[divan::bench]
174+
fn slice_empty_vortex(bencher: Bencher) {
175+
let buf = Buffer::<i32>::from_iter((0..1024).map(|i| i % i32::MAX));
176+
bencher.bench(|| divan::black_box(buf.slice(8..8)));
177+
}
178+
143179
#[divan::bench(args = INPUT_SIZE)]
144180
fn map_new_output(bencher: Bencher, n: i32) {
145181
bencher

0 commit comments

Comments
 (0)