@@ -23,7 +23,7 @@ use rand::Rng;
2323
2424extern crate arrow;
2525
26- use arrow:: compute:: take;
26+ use arrow:: compute:: { take, TakeOptions } ;
2727use arrow:: datatypes:: * ;
2828use arrow:: util:: test_util:: seedable_rng;
2929use arrow:: { array:: * , util:: bench_util:: * } ;
@@ -46,6 +46,12 @@ fn bench_take(values: &dyn Array, indices: &UInt32Array) {
4646 criterion:: black_box ( take ( values, & indices, None ) . unwrap ( ) ) ;
4747}
4848
49+ fn bench_take_bounds_check ( values : & dyn Array , indices : & UInt32Array ) {
50+ criterion:: black_box (
51+ take ( values, & indices, Some ( TakeOptions { check_bounds : true } ) ) . unwrap ( ) ,
52+ ) ;
53+ }
54+
4955fn add_benchmark ( c : & mut Criterion ) {
5056 let values = create_primitive_array :: < Int32Type > ( 512 , 0.0 ) ;
5157 let indices = create_random_index ( 512 , 0.0 ) ;
@@ -56,6 +62,17 @@ fn add_benchmark(c: &mut Criterion) {
5662 b. iter ( || bench_take ( & values, & indices) )
5763 } ) ;
5864
65+ let values = create_primitive_array :: < Int32Type > ( 512 , 0.0 ) ;
66+ let indices = create_random_index ( 512 , 0.0 ) ;
67+ c. bench_function ( "take check bounds i32 512" , |b| {
68+ b. iter ( || bench_take_bounds_check ( & values, & indices) )
69+ } ) ;
70+ let values = create_primitive_array :: < Int32Type > ( 1024 , 0.0 ) ;
71+ let indices = create_random_index ( 1024 , 0.0 ) ;
72+ c. bench_function ( "take check bounds i32 1024" , |b| {
73+ b. iter ( || bench_take_bounds_check ( & values, & indices) )
74+ } ) ;
75+
5976 let indices = create_random_index ( 512 , 0.5 ) ;
6077 c. bench_function ( "take i32 nulls 512" , |b| {
6178 b. iter ( || bench_take ( & values, & indices) )
0 commit comments