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


##########
arrow/benches/arithmetic_kernels.rs:
##########
@@ -60,5 +66,105 @@ fn add_benchmark(c: &mut Criterion) {
     }
 }
 
-criterion_group!(benches, add_benchmark);
+/// Like `create_primitive_array_range`, but with its own `seed`, so that two
+/// arrays hold different values and nulls.
+fn seeded_array<T>(

Review Comment:
   > Both PRs could then use one copy, and this file would stop conflicting 
between them.
   
   The two copies are identical, so they already merge into one. A trial merge 
of the two heads (`git merge-tree fe005b260b aee0225d39`) merges `seeded_array` 
cleanly. The file conflicts in the imports, in the new benchmark functions, and 
in `criterion_group!`, and moving the helper doesn't change any of those. The 
two PRs carry identical copies of what they share so that neither depends on 
the other 
(https://github.com/apache/arrow-rs/pull/12058#discussion_r4588942444). Only 
this file calls it, so I'd keep it here instead of adding a public function to 
`arrow::util::bench_util`.



##########
arrow/benches/arithmetic_kernels.rs:
##########
@@ -60,5 +66,105 @@ fn add_benchmark(c: &mut Criterion) {
     }
 }
 
-criterion_group!(benches, add_benchmark);
+/// Like `create_primitive_array_range`, but with its own `seed`, so that two
+/// arrays hold different values and nulls.
+fn seeded_array<T>(
+    size: usize,
+    null_density: f32,
+    range: Range<T::Native>,
+    seed: u64,
+) -> PrimitiveArray<T>
+where
+    T: ArrowPrimitiveType,
+    T::Native: SampleUniform,
+{
+    let mut rng = StdRng::seed_from_u64(seed);
+    (0..size)
+        .map(|_| (rng.random::<f32>() >= null_density).then(|| 
rng.random_range(range.clone())))
+        .collect()
+}
+
+/// Checked and wrapping integer arithmetic at DataFusion's default batch size.
+///
+/// The left operands come from `a_range` and the right ones from `b_range`, so
+/// the checked cases never overflow in a valid row unless the case name says
+/// so. Null slots hold 0, as a builder writes them, so with unsigned types
+/// `subtract_checked_scalar` overflows in null slots.
+fn integer_benchmark<T>(
+    c: &mut Criterion,
+    name: &str,
+    a_range: Range<T::Native>,
+    b_range: Range<T::Native>,
+    max: T::Native,

Review Comment:
   Done. `integer_benchmark` takes `max` from `MAX_TOTAL_ORDER`, and the 
overflow case builds its scalar with `new_scalar`. The arrays are the same as 
before.



-- 
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