Skip to content

Commit c113e29

Browse files
committed
bench: add lpad/rpad benchmarks without a fill argument
1 parent e732212 commit c113e29

1 file changed

Lines changed: 108 additions & 0 deletions

File tree

  • datafusion/functions/benches/unicode_expressions

‎datafusion/functions/benches/unicode_expressions/pad.rs‎

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,60 @@ fn criterion_benchmark(c: &mut Criterion) {
363363
},
364364
);
365365

366+
// Utf8 type without fill (pads with spaces)
367+
let mut args = create_pad_args::<i32>(size, 5, 20, false);
368+
args.truncate(2);
369+
let arg_fields = args
370+
.iter()
371+
.enumerate()
372+
.map(|(idx, arg)| {
373+
Field::new(format!("arg_{idx}"), arg.data_type(), true).into()
374+
})
375+
.collect::<Vec<_>>();
376+
377+
group.bench_function(
378+
format!("lpad utf8 no fill [size={size}, str_len=5, target=20]"),
379+
|b| {
380+
b.iter(|| {
381+
let args_cloned = args.clone();
382+
black_box(unicode::lpad().invoke_with_args(ScalarFunctionArgs {
383+
args: args_cloned,
384+
arg_fields: arg_fields.clone(),
385+
number_rows: size,
386+
return_field: Field::new("f", DataType::Utf8, true).into(),
387+
config_options: Arc::clone(&config_options),
388+
}))
389+
})
390+
},
391+
);
392+
393+
// Utf8 type with Unicode strings, without fill
394+
let mut args = create_unicode_pad_args(size, 20, false);
395+
args.truncate(2);
396+
let arg_fields = args
397+
.iter()
398+
.enumerate()
399+
.map(|(idx, arg)| {
400+
Field::new(format!("arg_{idx}"), arg.data_type(), true).into()
401+
})
402+
.collect::<Vec<_>>();
403+
404+
group.bench_function(
405+
format!("lpad utf8 unicode no fill [size={size}, target=20]"),
406+
|b| {
407+
b.iter(|| {
408+
let args_cloned = args.clone();
409+
black_box(unicode::lpad().invoke_with_args(ScalarFunctionArgs {
410+
args: args_cloned,
411+
arg_fields: arg_fields.clone(),
412+
number_rows: size,
413+
return_field: Field::new("f", DataType::Utf8, true).into(),
414+
config_options: Arc::clone(&config_options),
415+
}))
416+
})
417+
},
418+
);
419+
366420
// --- Scalar length + fill benchmarks ---
367421

368422
// Utf8 with scalar length and fill (3-arg)
@@ -641,6 +695,60 @@ fn criterion_benchmark(c: &mut Criterion) {
641695
},
642696
);
643697

698+
// Utf8 type without fill (pads with spaces)
699+
let mut args = create_pad_args::<i32>(size, 5, 20, false);
700+
args.truncate(2);
701+
let arg_fields = args
702+
.iter()
703+
.enumerate()
704+
.map(|(idx, arg)| {
705+
Field::new(format!("arg_{idx}"), arg.data_type(), true).into()
706+
})
707+
.collect::<Vec<_>>();
708+
709+
group.bench_function(
710+
format!("rpad utf8 no fill [size={size}, str_len=5, target=20]"),
711+
|b| {
712+
b.iter(|| {
713+
let args_cloned = args.clone();
714+
black_box(unicode::rpad().invoke_with_args(ScalarFunctionArgs {
715+
args: args_cloned,
716+
arg_fields: arg_fields.clone(),
717+
number_rows: size,
718+
return_field: Field::new("f", DataType::Utf8, true).into(),
719+
config_options: Arc::clone(&config_options),
720+
}))
721+
})
722+
},
723+
);
724+
725+
// Utf8 type with Unicode strings, without fill
726+
let mut args = create_unicode_pad_args(size, 20, false);
727+
args.truncate(2);
728+
let arg_fields = args
729+
.iter()
730+
.enumerate()
731+
.map(|(idx, arg)| {
732+
Field::new(format!("arg_{idx}"), arg.data_type(), true).into()
733+
})
734+
.collect::<Vec<_>>();
735+
736+
group.bench_function(
737+
format!("rpad utf8 unicode no fill [size={size}, target=20]"),
738+
|b| {
739+
b.iter(|| {
740+
let args_cloned = args.clone();
741+
black_box(unicode::rpad().invoke_with_args(ScalarFunctionArgs {
742+
args: args_cloned,
743+
arg_fields: arg_fields.clone(),
744+
number_rows: size,
745+
return_field: Field::new("f", DataType::Utf8, true).into(),
746+
config_options: Arc::clone(&config_options),
747+
}))
748+
})
749+
},
750+
);
751+
644752
// --- Scalar length + fill benchmarks ---
645753

646754
// Utf8 with scalar length and fill (3-arg)

0 commit comments

Comments
 (0)