tobixdev commented on code in PR #8543:
URL: https://github.com/apache/arrow-rs/pull/8543#discussion_r2404426628


##########
arrow/benches/array_from.rs:
##########
@@ -207,34 +206,47 @@ fn array_from_vec_benchmark(c: &mut Criterion) {
     });
 }
 
-fn gen_option_vector<TItem: Copy>(item: TItem, len: usize) -> 
Vec<Option<TItem>> {
-    hint::black_box(
-        repeat_n(item, len)
-            .enumerate()
-            .map(|(idx, item)| if idx % 3 == 0 { None } else { Some(item) })
-            .collect(),
-    )
+fn gen_option_iter<TItem: Clone + 'static>(
+    item: TItem,
+    len: usize,
+) -> Box<dyn Iterator<Item = Option<TItem>>> {
+    hint::black_box(Box::new(repeat_n(item, len).enumerate().map(
+        |(idx, item)| {
+            if idx % 3 == 0 {
+                None
+            } else {
+                Some(item)
+            }
+        },
+    )))
 }
 
 fn from_iter_benchmark(c: &mut Criterion) {
     const ITER_LEN: usize = 16_384;
 
     // All ArrowPrimitiveType use the same implementation
     c.bench_function("Int64Array::from_iter", |b| {
-        let values = gen_option_vector(1, ITER_LEN);
-        b.iter(|| hint::black_box(Int64Array::from_iter(values.iter())));
+        b.iter(|| hint::black_box(Int64Array::from_iter(gen_option_iter(1, 
ITER_LEN))));

Review Comment:
   @alamb The benchmarks are reverted and we should be able to re-run the 
benchmarks. Once this PR is merged I'll improve the benchmarks based on the 
feedback from @jhorstmann .



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