This is an automated email from the ASF dual-hosted git repository.
agrove pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion-comet.git
The following commit(s) were added to refs/heads/main by this push:
new cecfeb05 chore: Add criterion benchmark for decimal_div (#743)
cecfeb05 is described below
commit cecfeb05efe587aa2e91fa11b701dfc4fb825262
Author: Andy Grove <[email protected]>
AuthorDate: Wed Jul 31 10:57:46 2024 -0600
chore: Add criterion benchmark for decimal_div (#743)
---
native/spark-expr/Cargo.toml | 4 +++
native/spark-expr/benches/decimal_div.rs | 54 ++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+)
diff --git a/native/spark-expr/Cargo.toml b/native/spark-expr/Cargo.toml
index a535a2b8..96eae39f 100644
--- a/native/spark-expr/Cargo.toml
+++ b/native/spark-expr/Cargo.toml
@@ -64,3 +64,7 @@ harness = false
[[bench]]
name = "conditional"
harness = false
+
+[[bench]]
+name = "decimal_div"
+harness = false
diff --git a/native/spark-expr/benches/decimal_div.rs
b/native/spark-expr/benches/decimal_div.rs
new file mode 100644
index 00000000..89f06e50
--- /dev/null
+++ b/native/spark-expr/benches/decimal_div.rs
@@ -0,0 +1,54 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use arrow::compute::cast;
+use arrow_array::builder::Decimal128Builder;
+use arrow_schema::DataType;
+use criterion::{black_box, criterion_group, criterion_main, Criterion};
+use datafusion_comet_spark_expr::scalar_funcs::spark_decimal_div;
+use datafusion_expr::ColumnarValue;
+use std::sync::Arc;
+
+fn criterion_benchmark(c: &mut Criterion) {
+ // create input data
+ let mut c1 = Decimal128Builder::new();
+ let mut c2 = Decimal128Builder::new();
+ for i in 0..1000 {
+ c1.append_value(99999999 + i);
+ c2.append_value(88888888 - i);
+ }
+ let c1 = Arc::new(c1.finish());
+ let c2 = Arc::new(c2.finish());
+
+ let c1_type = DataType::Decimal128(10, 4);
+ let c1 = cast(c1.as_ref(), &c1_type).unwrap();
+ let c2_type = DataType::Decimal128(10, 3);
+ let c2 = cast(c2.as_ref(), &c2_type).unwrap();
+
+ let args = [ColumnarValue::Array(c1), ColumnarValue::Array(c2)];
+ c.bench_function("decimal_div", |b| {
+ b.iter(|| {
+ black_box(spark_decimal_div(
+ black_box(&args),
+ black_box(&DataType::Decimal128(10, 4)),
+ ))
+ })
+ });
+}
+
+criterion_group!(benches, criterion_benchmark);
+criterion_main!(benches);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]