Skip to content

Commit 032be4f

Browse files
committed
Benchmark deferred Boolean RowFn output
Signed-off-by: Connor Tsui <[email protected]>
1 parent a70dfcf commit 032be4f

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

‎vortex-array/benches/row_fn_output.rs‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ impl BenchPrimitive for i64 {
8888
#[derive(Clone)]
8989
struct InfallibleBool<T>(PhantomData<T>);
9090

91+
#[derive(Clone)]
92+
struct DeferredBool<T>(PhantomData<T>);
93+
9194
#[derive(Clone)]
9295
struct DeferredI64;
9396

@@ -112,6 +115,36 @@ impl<T: BenchPrimitive> RowFn for InfallibleBool<T> {
112115
}
113116
}
114117

118+
impl<T: BenchPrimitive> RowFn for DeferredBool<T> {
119+
type Options = EmptyOptions;
120+
121+
const ARG_NAMES: &'static [&'static str] = &["lhs", "rhs"];
122+
const INFALLIBLE: bool = false;
123+
124+
fn id(&self) -> ScalarFnId {
125+
static ID: CachedId = CachedId::new("bench.row_fn_output.deferred_bool");
126+
*ID
127+
}
128+
129+
fn dispatch<V: RowVisitor>(
130+
&self,
131+
_options: &Self::Options,
132+
_args: &[DType],
133+
visitor: V,
134+
) -> VortexResult<V::VisitResult> {
135+
visitor.visit_deferred::<(T, T), bool, bool>(
136+
|(lhs, rhs)| (lhs.is_lt(rhs), lhs.is_lt(T::default())),
137+
|negative| {
138+
vortex_ensure!(
139+
!negative,
140+
"deferred-bool benchmark inputs must be nonnegative"
141+
);
142+
Ok(())
143+
},
144+
)
145+
}
146+
}
147+
115148
impl RowFn for DeferredI64 {
116149
type Options = EmptyOptions;
117150

@@ -149,6 +182,13 @@ fn infallible_bool<T: BenchPrimitive>(bencher: Bencher, &shape: &InputShape) {
149182
bench_row_fn(bencher, &function, make_args::<T>(shape));
150183
}
151184

185+
#[vortex_bench_support::cpu_features]
186+
#[divan::bench(types = [i32, i64], args = INPUT_SHAPES)]
187+
fn deferred_bool<T: BenchPrimitive>(bencher: Bencher, &shape: &InputShape) {
188+
let function = DeferredBool::<T>(PhantomData);
189+
bench_row_fn(bencher, &function, make_args::<T>(shape));
190+
}
191+
152192
#[vortex_bench_support::cpu_features]
153193
#[divan::bench(args = INPUT_SHAPES)]
154194
fn deferred_i64(bencher: Bencher, &shape: &InputShape) {

0 commit comments

Comments
 (0)