mbutrovich commented on code in PR #12062:
URL: https://github.com/apache/arrow-rs/pull/12062#discussion_r4568415982


##########
arrow/benches/arithmetic_kernels.rs:
##########
@@ -60,5 +61,96 @@ fn add_benchmark(c: &mut Criterion) {
     }
 }
 
-criterion_group!(benches, add_benchmark);
+/// Decimal arithmetic at DataFusion's default batch size.
+///
+/// Values stay within six digits, so the cases never overflow unless the case
+/// name says so. `add` and `add_wrapping` run the same checked kernel for
+/// decimals, so only `add` is measured.
+fn decimal_benchmark(c: &mut Criterion) {
+    const BATCH_SIZE: usize = 8192;
+    let decimal128 = |null_density, scale| {
+        create_primitive_array_range::<Decimal128Type>(
+            BATCH_SIZE,
+            null_density,
+            -999_999..1_000_000,
+        )
+        .with_precision_and_scale(18, scale)
+        .unwrap()
+    };
+    for null_density in [0., 0.1] {
+        let a = decimal128(null_density, 2);
+        let b = decimal128(null_density, 2);
+        let b_scale4 = decimal128(null_density, 4);
+        let a64 = create_primitive_array_range::<Decimal64Type>(
+            BATCH_SIZE,
+            null_density,
+            -999_999..1_000_000,
+        )
+        .with_precision_and_scale(18, 2)
+        .unwrap();
+        let b64 = a64.clone();

Review Comment:
   > Could `b64`/`b256` be generated independently like `a`/`b` for Decimal128?
   
   Done. `a` and `b` weren't independent either: `create_primitive_array_range` 
seeds every call with the [same 
seed](https://github.com/apache/arrow-rs/blob/9c9486188744e80ec86c3b2bcdd649b89945ffe5/arrow/src/util/test_util.rs#L21-L23),
 so they held the same values and nulls. The benchmark now generates each 
operand with its own seed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to