Skip to content

Commit 67a138d

Browse files
committed
Add nullif_kernel benchmark
1 parent 3a7d538 commit 67a138d

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

arrow/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,12 @@ name = "bitwise_kernel"
306306
harness = false
307307
required-features = ["test_utils"]
308308

309+
[[bench]]
310+
name = "nullif_kernel"
311+
harness = false
312+
required-features = ["test_utils"]
313+
314+
309315
[[bench]]
310316
name = "lexsort"
311317
harness = false

arrow/benches/nullif_kernel.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
#[macro_use]
19+
extern crate criterion;
20+
use criterion::Criterion;
21+
22+
use arrow::util::bench_util::{create_boolean_array, create_primitive_array};
23+
24+
use arrow::array::*;
25+
use std::hint;
26+
use arrow_array::types::{Int64Type};
27+
use arrow_select::nullif::nullif;
28+
29+
fn bench_nullif(left: &dyn Array, right: &BooleanArray) {
30+
hint::black_box(nullif(left, right).unwrap());
31+
}
32+
33+
34+
fn add_benchmark(c: &mut Criterion) {
35+
let size = 8192usize;
36+
37+
// create input before benchmark to ensure allocations are consistent
38+
let int64_no_nulls = create_primitive_array::<Int64Type>(size, 0.0);
39+
let int64_nulls = create_primitive_array::<Int64Type>(size, 0.1);
40+
41+
let mask_10 = create_boolean_array(size, 0.0, 0.1);
42+
let mask_10_sliced = create_boolean_array(size+7, 0.0, 0.1).slice(7, size);
43+
let mask_1 = create_boolean_array(size, 0.0, 0.01);
44+
45+
c.bench_function("nullif no-nulls mask(10%)", |b| b.iter(|| bench_nullif(&int64_no_nulls, &mask_10)));
46+
c.bench_function("nullif no-nulls mask(10%, sliced)", |b| b.iter(|| bench_nullif(&int64_no_nulls, &mask_10_sliced)));
47+
c.bench_function("nullif no-nulls mask(1%)", |b| b.iter(|| bench_nullif(&int64_no_nulls, &mask_1)));
48+
49+
c.bench_function("nullif nulls mask(10%)", |b| b.iter(|| bench_nullif(&int64_nulls, &mask_10)));
50+
c.bench_function("nullif nulls mask(10%, sliced)", |b| b.iter(|| bench_nullif(&int64_nulls, &mask_10_sliced)));
51+
c.bench_function("nullif nulls mask(1%)", |b| b.iter(|| bench_nullif(&int64_nulls, &mask_1)));
52+
53+
}
54+
55+
criterion_group!(benches, add_benchmark);
56+
criterion_main!(benches);

0 commit comments

Comments
 (0)