1717
1818extern crate criterion;
1919
20+ use arrow:: datatypes:: DataType ;
2021use criterion:: { black_box, criterion_group, criterion_main, Criterion } ;
22+ use datafusion_expr:: ScalarFunctionArgs ;
2123use helper:: gen_string_array;
2224
2325mod helper;
@@ -26,6 +28,8 @@ fn criterion_benchmark(c: &mut Criterion) {
2628 // All benches are single batch run with 8192 rows
2729 let character_length = datafusion_functions:: unicode:: character_length ( ) ;
2830
31+ let return_type = DataType :: Utf8 ;
32+
2933 let n_rows = 8192 ;
3034 for str_len in [ 8 , 32 , 128 , 4096 ] {
3135 // StringArray ASCII only
@@ -34,8 +38,11 @@ fn criterion_benchmark(c: &mut Criterion) {
3438 & format ! ( "character_length_StringArray_ascii_str_len_{}" , str_len) ,
3539 |b| {
3640 b. iter ( || {
37- // TODO use invoke_with_args
38- black_box ( character_length. invoke_batch ( & args_string_ascii, n_rows) )
41+ black_box ( character_length. invoke_with_args ( ScalarFunctionArgs {
42+ args : args_string_ascii. clone ( ) ,
43+ number_rows : n_rows,
44+ return_type : & return_type,
45+ } ) )
3946 } )
4047 } ,
4148 ) ;
@@ -46,8 +53,11 @@ fn criterion_benchmark(c: &mut Criterion) {
4653 & format ! ( "character_length_StringArray_utf8_str_len_{}" , str_len) ,
4754 |b| {
4855 b. iter ( || {
49- // TODO use invoke_with_args
50- black_box ( character_length. invoke_batch ( & args_string_utf8, n_rows) )
56+ black_box ( character_length. invoke_with_args ( ScalarFunctionArgs {
57+ args : args_string_utf8. clone ( ) ,
58+ number_rows : n_rows,
59+ return_type : & return_type,
60+ } ) )
5161 } )
5262 } ,
5363 ) ;
@@ -58,10 +68,11 @@ fn criterion_benchmark(c: &mut Criterion) {
5868 & format ! ( "character_length_StringViewArray_ascii_str_len_{}" , str_len) ,
5969 |b| {
6070 b. iter ( || {
61- // TODO use invoke_with_args
62- black_box (
63- character_length. invoke_batch ( & args_string_view_ascii, n_rows) ,
64- )
71+ black_box ( character_length. invoke_with_args ( ScalarFunctionArgs {
72+ args : args_string_view_ascii. clone ( ) ,
73+ number_rows : n_rows,
74+ return_type : & return_type,
75+ } ) )
6576 } )
6677 } ,
6778 ) ;
@@ -72,10 +83,11 @@ fn criterion_benchmark(c: &mut Criterion) {
7283 & format ! ( "character_length_StringViewArray_utf8_str_len_{}" , str_len) ,
7384 |b| {
7485 b. iter ( || {
75- // TODO use invoke_with_args
76- black_box (
77- character_length. invoke_batch ( & args_string_view_utf8, n_rows) ,
78- )
86+ black_box ( character_length. invoke_with_args ( ScalarFunctionArgs {
87+ args : args_string_view_utf8. clone ( ) ,
88+ number_rows : n_rows,
89+ return_type : & return_type,
90+ } ) )
7991 } )
8092 } ,
8193 ) ;
0 commit comments