MCPcopy Create free account
hub / github.com/apache/datafusion / criterion_benchmark

Function criterion_benchmark

datafusion/functions/benches/initcap.rs:69–206  ·  view source on GitHub ↗
(c: &mut Criterion)

Source from the content-addressed store, hash-verified

67}
68
69fn criterion_benchmark(c: &mut Criterion) {
70 let initcap = unicode::initcap();
71 let config_options = Arc::new(ConfigOptions::default());
72
73 // Array benchmarks: vary both row count and string length
74 for size in [1024, 4096, 8192] {
75 for str_len in [16, 128] {
76 let mut group =
77 c.benchmark_group(format!("initcap size={size} str_len={str_len}"));
78 group.sampling_mode(SamplingMode::Flat);
79 group.sample_size(10);
80 group.measurement_time(Duration::from_secs(10));
81
82 // Utf8
83 let array_args = create_args::<i32>(size, str_len, false);
84 let array_arg_fields = vec![Field::new("arg_0", DataType::Utf8, true).into()];
85
86 group.bench_function("array_utf8", |b| {
87 b.iter(|| {
88 black_box(initcap.invoke_with_args(ScalarFunctionArgs {
89 args: array_args.clone(),
90 arg_fields: array_arg_fields.clone(),
91 number_rows: size,
92 return_field: Field::new("f", DataType::Utf8, true).into(),
93 config_options: Arc::clone(&config_options),
94 }))
95 })
96 });
97
98 // Utf8View
99 let array_view_args = create_args::<i32>(size, str_len, true);
100 let array_view_arg_fields =
101 vec![Field::new("arg_0", DataType::Utf8View, true).into()];
102
103 group.bench_function("array_utf8view", |b| {
104 b.iter(|| {
105 black_box(initcap.invoke_with_args(ScalarFunctionArgs {
106 args: array_view_args.clone(),
107 arg_fields: array_view_arg_fields.clone(),
108 number_rows: size,
109 return_field: Field::new("f", DataType::Utf8View, true).into(),
110 config_options: Arc::clone(&config_options),
111 }))
112 })
113 });
114
115 group.finish();
116 }
117 }
118
119 // Unicode array benchmarks
120 for size in [1024, 4096, 8192] {
121 let mut group = c.benchmark_group(format!("initcap unicode size={size}"));
122 group.sampling_mode(SamplingMode::Flat);
123 group.sample_size(10);
124 group.measurement_time(Duration::from_secs(10));
125
126 let unicode_args = create_unicode_utf8_args(size);

Callers

nothing calls this directly

Calls 9

initcapFunction · 0.85
newFunction · 0.85
create_unicode_utf8_argsFunction · 0.85
iterMethod · 0.45
invoke_with_argsMethod · 0.45
cloneMethod · 0.45
intoMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…