From a6b5f3e29b6b6a69cc26326c87da6f150de0bf7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Heres?= Date: Thu, 13 Aug 2026 20:21:20 +0200 Subject: [PATCH] bench(functions): group the 63 bench targets into 9 Each `[[bench]]` target is a separate binary that statically links this crate, arrow and criterion, so building this crate's benchmarks meant 63 link steps. Linking, not compiling, was the bulk of it: rebuilding a *single* bench target took 10.6s, of which the compile is a fraction. The 63 targets are grouped by their `required-features`, which keeps that semantics exactly as it was: string_expressions 16 benches math_expressions 16 unicode_expressions 12 datetime_expressions 8 regex_expressions 4 misc 4 (no required features) leaving `crypto`, `encoding` and `dictionary_encoding` standalone, since they are the only members of their feature groups. Each group file declares the individual benchmarks as modules and lists their criterion groups in one `criterion_main!`. The benchmark code itself is untouched: no `bench_function`, `benchmark_group` or `bench_with_input` line changes anywhere in the diff. Per file the change is only dropping `criterion_main!` (a module cannot define `main`), dropping the now-unused `criterion_main` import, dropping `extern crate criterion` (a no-op since edition 2018), and pointing the four users of `benches/helper.rs` at `crate::helper`. `autobenches = false` keeps cargo from picking the module files back up as targets of their own. Running a single benchmark still works, via criterion's filter: cargo bench --bench math_expressions -- power Co-Authored-By: Claude Opus 5 --- datafusion/functions/Cargo.toml | 288 +----------------- .../{ => datetime_expressions}/date_bin.rs | 3 +- .../{ => datetime_expressions}/date_part.rs | 3 +- .../{ => datetime_expressions}/date_trunc.rs | 3 +- .../benches/datetime_expressions/main.rs | 46 +++ .../{ => datetime_expressions}/make_date.rs | 3 +- .../{ => datetime_expressions}/to_char.rs | 3 +- .../to_local_time.rs | 3 +- .../{ => datetime_expressions}/to_time.rs | 3 +- .../to_timestamp.rs | 3 +- .../benches/{ => math_expressions}/atan2.rs | 5 +- .../benches/{ => math_expressions}/cot.rs | 3 +- .../{ => math_expressions}/factorial.rs | 3 +- .../{ => math_expressions}/floor_ceil.rs | 3 +- .../benches/{ => math_expressions}/gcd.rs | 3 +- .../benches/{ => math_expressions}/isnan.rs | 3 +- .../benches/{ => math_expressions}/iszero.rs | 3 +- .../benches/{ => math_expressions}/lcm.rs | 3 +- .../benches/math_expressions/main.rs | 62 ++++ .../benches/{ => math_expressions}/nanvl.rs | 5 +- .../benches/{ => math_expressions}/power.rs | 5 +- .../benches/{ => math_expressions}/random.rs | 3 +- .../benches/{ => math_expressions}/round.rs | 3 +- .../{ => math_expressions}/round_dense.rs | 3 +- .../benches/{ => math_expressions}/signum.rs | 3 +- .../benches/{ => math_expressions}/trunc.rs | 3 +- .../{ => math_expressions}/trunc_precision.rs | 3 +- .../functions/benches/{ => misc}/get_field.rs | 5 +- datafusion/functions/benches/misc/main.rs | 40 +++ .../functions/benches/{ => misc}/nullif.rs | 3 +- .../functions/benches/{ => misc}/overlay.rs | 7 +- .../functions/benches/{ => misc}/upper.rs | 3 +- .../benches/regex_expressions/main.rs | 38 +++ .../{ => regex_expressions}/regexp_count.rs | 3 +- .../{ => regex_expressions}/regexp_instr.rs | 3 +- .../{ => regex_expressions}/regexp_match.rs | 3 +- .../benches/{ => regex_expressions}/regx.rs | 3 +- .../benches/{ => string_expressions}/ascii.rs | 7 +- .../benches/{ => string_expressions}/chr.rs | 3 +- .../{ => string_expressions}/concat.rs | 3 +- .../{ => string_expressions}/concat_ws.rs | 3 +- .../{ => string_expressions}/contains.rs | 3 +- .../{ => string_expressions}/ends_with.rs | 3 +- .../benches/{ => string_expressions}/lower.rs | 3 +- .../benches/string_expressions/main.rs | 64 ++++ .../{ => string_expressions}/repeat.rs | 3 +- .../{ => string_expressions}/replace.rs | 3 +- .../replace_scalar.rs | 3 +- .../{ => string_expressions}/split_part.rs | 3 +- .../{ => string_expressions}/starts_with.rs | 3 +- .../{ => string_expressions}/to_hex.rs | 3 +- .../benches/{ => string_expressions}/trim.rs | 4 +- .../{ => string_expressions}/upper_unicode.rs | 3 +- .../benches/{ => string_expressions}/uuid.rs | 3 +- .../character_length.rs | 7 +- .../{ => unicode_expressions}/find_in_set.rs | 3 +- .../find_in_set_literal.rs | 3 +- .../{ => unicode_expressions}/initcap.rs | 3 +- .../{ => unicode_expressions}/left_right.rs | 3 +- .../{ => unicode_expressions}/levenshtein.rs | 3 +- .../benches/unicode_expressions/main.rs | 56 ++++ .../benches/{ => unicode_expressions}/pad.rs | 3 +- .../{ => unicode_expressions}/reverse.rs | 7 +- .../{ => unicode_expressions}/strpos.rs | 3 +- .../{ => unicode_expressions}/substr.rs | 3 +- .../{ => unicode_expressions}/substr_index.rs | 3 +- .../{ => unicode_expressions}/translate.rs | 3 +- 67 files changed, 381 insertions(+), 418 deletions(-) rename datafusion/functions/benches/{ => datetime_expressions}/date_bin.rs (96%) rename datafusion/functions/benches/{ => datetime_expressions}/date_part.rs (99%) rename datafusion/functions/benches/{ => datetime_expressions}/date_trunc.rs (97%) create mode 100644 datafusion/functions/benches/datetime_expressions/main.rs rename datafusion/functions/benches/{ => datetime_expressions}/make_date.rs (98%) rename datafusion/functions/benches/{ => datetime_expressions}/to_char.rs (99%) rename datafusion/functions/benches/{ => datetime_expressions}/to_local_time.rs (97%) rename datafusion/functions/benches/{ => datetime_expressions}/to_time.rs (97%) rename datafusion/functions/benches/{ => datetime_expressions}/to_timestamp.rs (99%) rename datafusion/functions/benches/{ => math_expressions}/atan2.rs (98%) rename datafusion/functions/benches/{ => math_expressions}/cot.rs (98%) rename datafusion/functions/benches/{ => math_expressions}/factorial.rs (96%) rename datafusion/functions/benches/{ => math_expressions}/floor_ceil.rs (98%) rename datafusion/functions/benches/{ => math_expressions}/gcd.rs (97%) rename datafusion/functions/benches/{ => math_expressions}/isnan.rs (97%) rename datafusion/functions/benches/{ => math_expressions}/iszero.rs (98%) rename datafusion/functions/benches/{ => math_expressions}/lcm.rs (96%) create mode 100644 datafusion/functions/benches/math_expressions/main.rs rename datafusion/functions/benches/{ => math_expressions}/nanvl.rs (98%) rename datafusion/functions/benches/{ => math_expressions}/power.rs (97%) rename datafusion/functions/benches/{ => math_expressions}/random.rs (97%) rename datafusion/functions/benches/{ => math_expressions}/round.rs (98%) rename datafusion/functions/benches/{ => math_expressions}/round_dense.rs (97%) rename datafusion/functions/benches/{ => math_expressions}/signum.rs (98%) rename datafusion/functions/benches/{ => math_expressions}/trunc.rs (98%) rename datafusion/functions/benches/{ => math_expressions}/trunc_precision.rs (97%) rename datafusion/functions/benches/{ => misc}/get_field.rs (96%) create mode 100644 datafusion/functions/benches/misc/main.rs rename datafusion/functions/benches/{ => misc}/nullif.rs (96%) rename datafusion/functions/benches/{ => misc}/overlay.rs (97%) rename datafusion/functions/benches/{ => misc}/upper.rs (96%) create mode 100644 datafusion/functions/benches/regex_expressions/main.rs rename datafusion/functions/benches/{ => regex_expressions}/regexp_count.rs (97%) rename datafusion/functions/benches/{ => regex_expressions}/regexp_instr.rs (97%) rename datafusion/functions/benches/{ => regex_expressions}/regexp_match.rs (98%) rename datafusion/functions/benches/{ => regex_expressions}/regx.rs (99%) rename datafusion/functions/benches/{ => string_expressions}/ascii.rs (98%) rename datafusion/functions/benches/{ => string_expressions}/chr.rs (97%) rename datafusion/functions/benches/{ => string_expressions}/concat.rs (98%) rename datafusion/functions/benches/{ => string_expressions}/concat_ws.rs (97%) rename datafusion/functions/benches/{ => string_expressions}/contains.rs (98%) rename datafusion/functions/benches/{ => string_expressions}/ends_with.rs (98%) rename datafusion/functions/benches/{ => string_expressions}/lower.rs (99%) create mode 100644 datafusion/functions/benches/string_expressions/main.rs rename datafusion/functions/benches/{ => string_expressions}/repeat.rs (98%) rename datafusion/functions/benches/{ => string_expressions}/replace.rs (98%) rename datafusion/functions/benches/{ => string_expressions}/replace_scalar.rs (97%) rename datafusion/functions/benches/{ => string_expressions}/split_part.rs (98%) rename datafusion/functions/benches/{ => string_expressions}/starts_with.rs (98%) rename datafusion/functions/benches/{ => string_expressions}/to_hex.rs (98%) rename datafusion/functions/benches/{ => string_expressions}/trim.rs (98%) rename datafusion/functions/benches/{ => string_expressions}/upper_unicode.rs (97%) rename datafusion/functions/benches/{ => string_expressions}/uuid.rs (94%) rename datafusion/functions/benches/{ => unicode_expressions}/character_length.rs (97%) rename datafusion/functions/benches/{ => unicode_expressions}/find_in_set.rs (98%) rename datafusion/functions/benches/{ => unicode_expressions}/find_in_set_literal.rs (97%) rename datafusion/functions/benches/{ => unicode_expressions}/initcap.rs (98%) rename datafusion/functions/benches/{ => unicode_expressions}/left_right.rs (97%) rename datafusion/functions/benches/{ => unicode_expressions}/levenshtein.rs (96%) create mode 100644 datafusion/functions/benches/unicode_expressions/main.rs rename datafusion/functions/benches/{ => unicode_expressions}/pad.rs (99%) rename datafusion/functions/benches/{ => unicode_expressions}/reverse.rs (97%) rename datafusion/functions/benches/{ => unicode_expressions}/strpos.rs (98%) rename datafusion/functions/benches/{ => unicode_expressions}/substr.rs (99%) rename datafusion/functions/benches/{ => unicode_expressions}/substr_index.rs (99%) rename datafusion/functions/benches/{ => unicode_expressions}/translate.rs (98%) diff --git a/datafusion/functions/Cargo.toml b/datafusion/functions/Cargo.toml index a170e9f07c39f..00d1531a3a771 100644 --- a/datafusion/functions/Cargo.toml +++ b/datafusion/functions/Cargo.toml @@ -100,270 +100,34 @@ tokio = { workspace = true, features = ["macros", "rt", "sync"] } [[bench]] harness = false -name = "replace_scalar" -required-features = ["string_expressions"] - -[[bench]] -harness = false -name = "round_dense" -required-features = ["math_expressions"] - -[[bench]] -harness = false -name = "ascii" -required-features = ["string_expressions"] - -[[bench]] -harness = false -name = "concat" -required-features = ["string_expressions"] - -[[bench]] -harness = false -name = "concat_ws" -required-features = ["string_expressions"] - -[[bench]] -harness = false -name = "to_timestamp" +name = "datetime_expressions" required-features = ["datetime_expressions"] [[bench]] harness = false -name = "encoding" -required-features = ["encoding_expressions"] - -[[bench]] -harness = false -name = "chr" -required-features = ["string_expressions"] - -[[bench]] -harness = false -name = "gcd" -required-features = ["math_expressions"] - -[[bench]] -harness = false -name = "lcm" -required-features = ["math_expressions"] - -[[bench]] -harness = false -name = "nanvl" +name = "math_expressions" required-features = ["math_expressions"] [[bench]] harness = false -name = "uuid" -required-features = ["string_expressions"] - -[[bench]] -harness = false -name = "to_hex" -required-features = ["string_expressions"] - -[[bench]] -harness = false -name = "regexp_match" -required-features = ["regex_expressions"] +name = "misc" +required-features = [] [[bench]] harness = false -name = "regx" +name = "regex_expressions" required-features = ["regex_expressions"] [[bench]] harness = false -name = "make_date" -required-features = ["datetime_expressions"] - -[[bench]] -harness = false -name = "iszero" -required-features = ["math_expressions"] - -[[bench]] -harness = false -name = "nullif" - -[[bench]] -harness = false -name = "date_bin" -required-features = ["datetime_expressions"] - -[[bench]] -harness = false -name = "date_trunc" -required-features = ["datetime_expressions"] - -[[bench]] -harness = false -name = "date_part" -required-features = ["datetime_expressions"] - -[[bench]] -harness = false -name = "to_char" -required-features = ["datetime_expressions"] - -[[bench]] -harness = false -name = "to_local_time" -required-features = ["datetime_expressions"] - -[[bench]] -harness = false -name = "to_time" -required-features = ["datetime_expressions"] - -[[bench]] -harness = false -name = "isnan" -required-features = ["math_expressions"] - -[[bench]] -harness = false -name = "signum" -required-features = ["math_expressions"] - -[[bench]] -harness = false -name = "atan2" -required-features = ["math_expressions"] - -[[bench]] -harness = false -name = "power" -required-features = ["math_expressions"] - -[[bench]] -harness = false -name = "substr_index" -required-features = ["unicode_expressions"] - -[[bench]] -harness = false -name = "trim" -required-features = ["string_expressions"] - -[[bench]] -harness = false -name = "lower" +name = "string_expressions" required-features = ["string_expressions"] [[bench]] harness = false -name = "upper" - -[[bench]] -harness = false -name = "upper_unicode" -required-features = ["string_expressions"] - -[[bench]] -harness = false -name = "pad" -required-features = ["unicode_expressions"] - -[[bench]] -harness = false -name = "repeat" -required-features = ["string_expressions"] - -[[bench]] -harness = false -name = "replace" -required-features = ["string_expressions"] - -[[bench]] -harness = false -name = "overlay" - -[[bench]] -harness = false -name = "random" -required-features = ["math_expressions"] - -[[bench]] -harness = false -name = "substr" -required-features = ["unicode_expressions"] - -[[bench]] -harness = false -name = "character_length" -required-features = ["unicode_expressions"] - -[[bench]] -harness = false -name = "cot" -required-features = ["math_expressions"] - -[[bench]] -harness = false -name = "strpos" -required-features = ["unicode_expressions"] - -[[bench]] -harness = false -name = "reverse" -required-features = ["unicode_expressions"] - -[[bench]] -harness = false -name = "trunc" -required-features = ["math_expressions"] - -[[bench]] -harness = false -name = "trunc_precision" -required-features = ["math_expressions"] - -[[bench]] -harness = false -name = "initcap" -required-features = ["unicode_expressions"] - -[[bench]] -harness = false -name = "find_in_set" -required-features = ["unicode_expressions"] - -[[bench]] -harness = false -name = "find_in_set_literal" +name = "unicode_expressions" required-features = ["unicode_expressions"] -[[bench]] -harness = false -name = "contains" -required-features = ["string_expressions"] - -[[bench]] -harness = false -name = "starts_with" -required-features = ["string_expressions"] - -[[bench]] -harness = false -name = "ends_with" -required-features = ["string_expressions"] - -[[bench]] -harness = false -name = "regexp_count" -required-features = ["regex_expressions"] - -[[bench]] -harness = false -name = "regexp_instr" -required-features = ["regex_expressions"] - -[[bench]] -harness = false -name = "get_field" - [[bench]] harness = false name = "crypto" @@ -371,40 +135,10 @@ required-features = ["crypto_expressions"] [[bench]] harness = false -name = "translate" -required-features = ["unicode_expressions"] - -[[bench]] -harness = false -name = "levenshtein" -required-features = ["unicode_expressions"] - -[[bench]] -harness = false -name = "split_part" -required-features = ["string_expressions"] - -[[bench]] -harness = false -name = "left_right" -required-features = ["unicode_expressions"] - -[[bench]] -harness = false -name = "factorial" -required-features = ["math_expressions"] - -[[bench]] -harness = false -name = "floor_ceil" -required-features = ["math_expressions"] - -[[bench]] -harness = false -name = "round" -required-features = ["math_expressions"] +name = "dictionary_encoding" +required-features = ["string_expressions", "unicode_expressions"] [[bench]] harness = false -name = "dictionary_encoding" -required-features = ["string_expressions", "unicode_expressions"] +name = "encoding" +required-features = ["encoding_expressions"] diff --git a/datafusion/functions/benches/date_bin.rs b/datafusion/functions/benches/datetime_expressions/date_bin.rs similarity index 96% rename from datafusion/functions/benches/date_bin.rs rename to datafusion/functions/benches/datetime_expressions/date_bin.rs index bae1438fa4d5b..d5a29ce1f3bde 100644 --- a/datafusion/functions/benches/date_bin.rs +++ b/datafusion/functions/benches/datetime_expressions/date_bin.rs @@ -20,7 +20,7 @@ use std::sync::Arc; use arrow::array::{Array, ArrayRef, TimestampSecondArray}; use arrow::datatypes::Field; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -71,4 +71,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/date_part.rs b/datafusion/functions/benches/datetime_expressions/date_part.rs similarity index 99% rename from datafusion/functions/benches/date_part.rs rename to datafusion/functions/benches/datetime_expressions/date_part.rs index fb93ebd03b4e2..aa4b3e1dba5c1 100644 --- a/datafusion/functions/benches/date_part.rs +++ b/datafusion/functions/benches/datetime_expressions/date_part.rs @@ -27,7 +27,7 @@ use arrow::array::{ TimestampNanosecondArray, TimestampSecondArray, }; use arrow::datatypes::{DataType, Field}; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs, ScalarUDF}; @@ -346,4 +346,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/date_trunc.rs b/datafusion/functions/benches/datetime_expressions/date_trunc.rs similarity index 97% rename from datafusion/functions/benches/date_trunc.rs rename to datafusion/functions/benches/datetime_expressions/date_trunc.rs index e2372fff2a02e..b00c2b4a6077b 100644 --- a/datafusion/functions/benches/date_trunc.rs +++ b/datafusion/functions/benches/datetime_expressions/date_trunc.rs @@ -20,7 +20,7 @@ use std::sync::Arc; use arrow::array::{Array, ArrayRef, TimestampNanosecondArray, TimestampSecondArray}; use arrow::datatypes::Field; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ReturnFieldArgs, ScalarFunctionArgs}; @@ -110,4 +110,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/datetime_expressions/main.rs b/datafusion/functions/benches/datetime_expressions/main.rs new file mode 100644 index 0000000000000..8a3fd8e967ece --- /dev/null +++ b/datafusion/functions/benches/datetime_expressions/main.rs @@ -0,0 +1,46 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! Benchmarks for functions behind the `datetime_expressions` feature. +//! +//! Each benchmark beside this file is a module rather than its own `[[bench]]` +//! target: a separate target per benchmark means a separate binary to link, +//! which dominated the cost of building this crate's benchmarks. +//! +//! Run one of them with `cargo bench --bench datetime_expressions -- `. + +use criterion::criterion_main; + +mod date_bin; +mod date_part; +mod date_trunc; +mod make_date; +mod to_char; +mod to_local_time; +mod to_time; +mod to_timestamp; + +criterion_main!( + date_bin::benches, + date_part::benches, + date_trunc::benches, + make_date::benches, + to_char::benches, + to_local_time::benches, + to_time::benches, + to_timestamp::benches, +); diff --git a/datafusion/functions/benches/make_date.rs b/datafusion/functions/benches/datetime_expressions/make_date.rs similarity index 98% rename from datafusion/functions/benches/make_date.rs rename to datafusion/functions/benches/datetime_expressions/make_date.rs index 2e82a871eb0d6..8b23e9d35b0a8 100644 --- a/datafusion/functions/benches/make_date.rs +++ b/datafusion/functions/benches/datetime_expressions/make_date.rs @@ -20,7 +20,7 @@ use std::sync::Arc; use arrow::array::{Array, ArrayRef, Int32Array}; use arrow::datatypes::{DataType, Field}; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -173,4 +173,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/to_char.rs b/datafusion/functions/benches/datetime_expressions/to_char.rs similarity index 99% rename from datafusion/functions/benches/to_char.rs rename to datafusion/functions/benches/datetime_expressions/to_char.rs index 8a9497bb33aa7..2be28806c9e8c 100644 --- a/datafusion/functions/benches/to_char.rs +++ b/datafusion/functions/benches/datetime_expressions/to_char.rs @@ -22,7 +22,7 @@ use arrow::array::{ArrayRef, Date32Array, Date64Array, StringArray}; use arrow::datatypes::{DataType, Field}; use chrono::TimeDelta; use chrono::prelude::*; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -339,4 +339,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/to_local_time.rs b/datafusion/functions/benches/datetime_expressions/to_local_time.rs similarity index 97% rename from datafusion/functions/benches/to_local_time.rs rename to datafusion/functions/benches/datetime_expressions/to_local_time.rs index 04440bf0ac28a..f29453e326f10 100644 --- a/datafusion/functions/benches/to_local_time.rs +++ b/datafusion/functions/benches/datetime_expressions/to_local_time.rs @@ -20,7 +20,7 @@ use std::sync::Arc; use arrow::array::{Array, ArrayRef, TimestampNanosecondArray}; use arrow::datatypes::Field; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; use datafusion_functions::datetime::to_local_time; @@ -86,4 +86,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/to_time.rs b/datafusion/functions/benches/datetime_expressions/to_time.rs similarity index 97% rename from datafusion/functions/benches/to_time.rs rename to datafusion/functions/benches/datetime_expressions/to_time.rs index f4499e2a7d0ba..953d2c80c5521 100644 --- a/datafusion/functions/benches/to_time.rs +++ b/datafusion/functions/benches/datetime_expressions/to_time.rs @@ -20,7 +20,7 @@ use std::sync::Arc; use arrow::array::{Array, ArrayRef, StringArray}; use arrow::datatypes::Field; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; use datafusion_functions::datetime::to_time; @@ -90,4 +90,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/to_timestamp.rs b/datafusion/functions/benches/datetime_expressions/to_timestamp.rs similarity index 99% rename from datafusion/functions/benches/to_timestamp.rs rename to datafusion/functions/benches/datetime_expressions/to_timestamp.rs index 90ea145d5d2c0..79a9395a6e0db 100644 --- a/datafusion/functions/benches/to_timestamp.rs +++ b/datafusion/functions/benches/datetime_expressions/to_timestamp.rs @@ -22,7 +22,7 @@ use arrow::array::builder::StringBuilder; use arrow::array::{Array, ArrayRef, StringArray}; use arrow::compute::cast; use arrow::datatypes::{DataType, Field, TimeUnit}; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; use datafusion_functions::datetime::to_timestamp; @@ -302,4 +302,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/atan2.rs b/datafusion/functions/benches/math_expressions/atan2.rs similarity index 98% rename from datafusion/functions/benches/atan2.rs rename to datafusion/functions/benches/math_expressions/atan2.rs index f1c9756a0cc08..e1f6727e40eb0 100644 --- a/datafusion/functions/benches/atan2.rs +++ b/datafusion/functions/benches/math_expressions/atan2.rs @@ -15,11 +15,9 @@ // specific language governing permissions and limitations // under the License. -extern crate criterion; - use arrow::datatypes::{DataType, Field, Float32Type, Float64Type}; use arrow::util::bench_util::create_primitive_array; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -143,4 +141,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/cot.rs b/datafusion/functions/benches/math_expressions/cot.rs similarity index 98% rename from datafusion/functions/benches/cot.rs rename to datafusion/functions/benches/math_expressions/cot.rs index 16c3fba2175fe..7d37a474f6d14 100644 --- a/datafusion/functions/benches/cot.rs +++ b/datafusion/functions/benches/math_expressions/cot.rs @@ -19,7 +19,7 @@ use arrow::{ datatypes::{Float32Type, Float64Type}, util::bench_util::create_primitive_array, }; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; use datafusion_functions::math::cot; use std::hint::black_box; @@ -132,4 +132,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/factorial.rs b/datafusion/functions/benches/math_expressions/factorial.rs similarity index 96% rename from datafusion/functions/benches/factorial.rs rename to datafusion/functions/benches/math_expressions/factorial.rs index c441b50c288c3..f12d672d9ef5e 100644 --- a/datafusion/functions/benches/factorial.rs +++ b/datafusion/functions/benches/math_expressions/factorial.rs @@ -17,7 +17,7 @@ use arrow::array::Int64Array; use arrow::datatypes::{DataType, Field}; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::ScalarFunctionArgs; @@ -62,4 +62,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/floor_ceil.rs b/datafusion/functions/benches/math_expressions/floor_ceil.rs similarity index 98% rename from datafusion/functions/benches/floor_ceil.rs rename to datafusion/functions/benches/math_expressions/floor_ceil.rs index dc095e0152c4d..4f13ab9eb82d6 100644 --- a/datafusion/functions/benches/floor_ceil.rs +++ b/datafusion/functions/benches/math_expressions/floor_ceil.rs @@ -17,7 +17,7 @@ use arrow::datatypes::{DataType, Field, Float64Type}; use arrow::util::bench_util::create_primitive_array; -use criterion::{Criterion, SamplingMode, criterion_group, criterion_main}; +use criterion::{Criterion, SamplingMode, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -130,4 +130,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/gcd.rs b/datafusion/functions/benches/math_expressions/gcd.rs similarity index 97% rename from datafusion/functions/benches/gcd.rs rename to datafusion/functions/benches/math_expressions/gcd.rs index ca49415b0f679..e702a6a6b0acf 100644 --- a/datafusion/functions/benches/gcd.rs +++ b/datafusion/functions/benches/math_expressions/gcd.rs @@ -20,7 +20,7 @@ use arrow::{ array::{ArrayRef, Int64Array}, datatypes::DataType, }; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -106,4 +106,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/isnan.rs b/datafusion/functions/benches/math_expressions/isnan.rs similarity index 97% rename from datafusion/functions/benches/isnan.rs rename to datafusion/functions/benches/math_expressions/isnan.rs index e353b9d27a0a1..bc5340aa05da6 100644 --- a/datafusion/functions/benches/isnan.rs +++ b/datafusion/functions/benches/math_expressions/isnan.rs @@ -20,7 +20,7 @@ use arrow::{ datatypes::{Float32Type, Float64Type}, util::bench_util::create_primitive_array, }; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; use datafusion_functions::math::isnan; @@ -84,4 +84,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/iszero.rs b/datafusion/functions/benches/math_expressions/iszero.rs similarity index 98% rename from datafusion/functions/benches/iszero.rs rename to datafusion/functions/benches/math_expressions/iszero.rs index c6d0aed4c615c..17bff665d334a 100644 --- a/datafusion/functions/benches/iszero.rs +++ b/datafusion/functions/benches/math_expressions/iszero.rs @@ -20,7 +20,7 @@ use arrow::{ datatypes::{Float32Type, Float64Type}, util::bench_util::create_primitive_array, }; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -132,4 +132,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/lcm.rs b/datafusion/functions/benches/math_expressions/lcm.rs similarity index 96% rename from datafusion/functions/benches/lcm.rs rename to datafusion/functions/benches/math_expressions/lcm.rs index 5a4e5d2bced7d..33f40f16a3e5d 100644 --- a/datafusion/functions/benches/lcm.rs +++ b/datafusion/functions/benches/math_expressions/lcm.rs @@ -20,7 +20,7 @@ use arrow::{ array::{ArrayRef, Int64Array}, datatypes::DataType, }; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; use datafusion_functions::math::lcm; @@ -63,4 +63,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/math_expressions/main.rs b/datafusion/functions/benches/math_expressions/main.rs new file mode 100644 index 0000000000000..f52a55cbabc4e --- /dev/null +++ b/datafusion/functions/benches/math_expressions/main.rs @@ -0,0 +1,62 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! Benchmarks for functions behind the `math_expressions` feature. +//! +//! Each benchmark beside this file is a module rather than its own `[[bench]]` +//! target: a separate target per benchmark means a separate binary to link, +//! which dominated the cost of building this crate's benchmarks. +//! +//! Run one of them with `cargo bench --bench math_expressions -- `. + +use criterion::criterion_main; + +mod atan2; +mod cot; +mod factorial; +mod floor_ceil; +mod gcd; +mod isnan; +mod iszero; +mod lcm; +mod nanvl; +mod power; +mod random; +mod round; +mod round_dense; +mod signum; +mod trunc; +mod trunc_precision; + +criterion_main!( + atan2::benches, + cot::benches, + factorial::benches, + floor_ceil::benches, + gcd::benches, + isnan::benches, + iszero::benches, + lcm::benches, + nanvl::benches, + power::benches, + random::benches, + round::benches, + round_dense::benches, + signum::benches, + trunc::benches, + trunc_precision::benches, +); diff --git a/datafusion/functions/benches/nanvl.rs b/datafusion/functions/benches/math_expressions/nanvl.rs similarity index 98% rename from datafusion/functions/benches/nanvl.rs rename to datafusion/functions/benches/math_expressions/nanvl.rs index d3d2c7ebff998..c2e507ed219bc 100644 --- a/datafusion/functions/benches/nanvl.rs +++ b/datafusion/functions/benches/math_expressions/nanvl.rs @@ -15,11 +15,9 @@ // specific language governing permissions and limitations // under the License. -extern crate criterion; - use arrow::array::{ArrayRef, Float32Array, Float64Array}; use arrow::datatypes::{DataType, Field}; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -185,4 +183,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/power.rs b/datafusion/functions/benches/math_expressions/power.rs similarity index 97% rename from datafusion/functions/benches/power.rs rename to datafusion/functions/benches/math_expressions/power.rs index 5336e42ebe59b..eed0e55aa3894 100644 --- a/datafusion/functions/benches/power.rs +++ b/datafusion/functions/benches/math_expressions/power.rs @@ -23,11 +23,9 @@ //! through a Float64 round-trip, which is measurably slower than the //! decimal kernel for the cases the kernel can handle. -extern crate criterion; - use arrow::array::{Decimal128Array, Int64Array}; use arrow::datatypes::{DataType, Field, FieldRef}; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs, ScalarUDF}; @@ -137,4 +135,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/random.rs b/datafusion/functions/benches/math_expressions/random.rs similarity index 97% rename from datafusion/functions/benches/random.rs rename to datafusion/functions/benches/math_expressions/random.rs index 71ded120eb515..0de60954f38c8 100644 --- a/datafusion/functions/benches/random.rs +++ b/datafusion/functions/benches/math_expressions/random.rs @@ -16,7 +16,7 @@ // under the License. use arrow::datatypes::{DataType, Field}; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ScalarFunctionArgs, ScalarUDFImpl}; use datafusion_functions::math::random::RandomFunc; @@ -71,4 +71,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/round.rs b/datafusion/functions/benches/math_expressions/round.rs similarity index 98% rename from datafusion/functions/benches/round.rs rename to datafusion/functions/benches/math_expressions/round.rs index 7010aa3507dbc..11c297aa5cb07 100644 --- a/datafusion/functions/benches/round.rs +++ b/datafusion/functions/benches/math_expressions/round.rs @@ -17,7 +17,7 @@ use arrow::datatypes::{DataType, Field, Float32Type, Float64Type}; use arrow::util::bench_util::create_primitive_array; -use criterion::{Criterion, SamplingMode, criterion_group, criterion_main}; +use criterion::{Criterion, SamplingMode, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -149,4 +149,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/round_dense.rs b/datafusion/functions/benches/math_expressions/round_dense.rs similarity index 97% rename from datafusion/functions/benches/round_dense.rs rename to datafusion/functions/benches/math_expressions/round_dense.rs index 2c37849bde489..c0320eaa622e7 100644 --- a/datafusion/functions/benches/round_dense.rs +++ b/datafusion/functions/benches/math_expressions/round_dense.rs @@ -21,7 +21,7 @@ use arrow::array::ArrayRef; use arrow::datatypes::{DataType, Field, Float32Type, Float64Type}; use arrow::util::bench_util::create_primitive_array; -use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main}; +use criterion::{BenchmarkId, Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs, ScalarUDFImpl}; @@ -91,4 +91,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/signum.rs b/datafusion/functions/benches/math_expressions/signum.rs similarity index 98% rename from datafusion/functions/benches/signum.rs rename to datafusion/functions/benches/math_expressions/signum.rs index e98d1b2c22ea2..8a6289c77f1ef 100644 --- a/datafusion/functions/benches/signum.rs +++ b/datafusion/functions/benches/math_expressions/signum.rs @@ -20,7 +20,7 @@ use arrow::{ datatypes::{Field, Float32Type, Float64Type}, util::bench_util::create_primitive_array, }; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -136,4 +136,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/trunc.rs b/datafusion/functions/benches/math_expressions/trunc.rs similarity index 98% rename from datafusion/functions/benches/trunc.rs rename to datafusion/functions/benches/math_expressions/trunc.rs index ffbedcb142c71..2b17f62952a3f 100644 --- a/datafusion/functions/benches/trunc.rs +++ b/datafusion/functions/benches/math_expressions/trunc.rs @@ -19,7 +19,7 @@ use arrow::{ datatypes::{Field, Float32Type, Float64Type}, util::bench_util::create_primitive_array, }; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; use datafusion_functions::math::trunc; use std::hint::black_box; @@ -121,4 +121,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/trunc_precision.rs b/datafusion/functions/benches/math_expressions/trunc_precision.rs similarity index 97% rename from datafusion/functions/benches/trunc_precision.rs rename to datafusion/functions/benches/math_expressions/trunc_precision.rs index 5d75694d6ed2f..e9a2aa894b3c2 100644 --- a/datafusion/functions/benches/trunc_precision.rs +++ b/datafusion/functions/benches/math_expressions/trunc_precision.rs @@ -20,7 +20,7 @@ use arrow::datatypes::{DataType, Field, Float32Type, Float64Type}; use arrow::util::bench_util::create_primitive_array; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -88,4 +88,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/get_field.rs b/datafusion/functions/benches/misc/get_field.rs similarity index 96% rename from datafusion/functions/benches/get_field.rs rename to datafusion/functions/benches/misc/get_field.rs index 8a5fd0a1e2fa9..b405e235420a5 100644 --- a/datafusion/functions/benches/get_field.rs +++ b/datafusion/functions/benches/misc/get_field.rs @@ -15,11 +15,9 @@ // specific language governing permissions and limitations // under the License. -extern crate criterion; - use arrow::array::{ArrayRef, Int32Builder, MapBuilder, StringBuilder}; use arrow::datatypes::{DataType, Field}; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -92,4 +90,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/misc/main.rs b/datafusion/functions/benches/misc/main.rs new file mode 100644 index 0000000000000..147c04f16811b --- /dev/null +++ b/datafusion/functions/benches/misc/main.rs @@ -0,0 +1,40 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! Benchmarks for functions behind the `` feature. +//! +//! Each benchmark beside this file is a module rather than its own `[[bench]]` +//! target: a separate target per benchmark means a separate binary to link, +//! which dominated the cost of building this crate's benchmarks. +//! +//! Run one of them with `cargo bench --bench misc -- `. + +use criterion::criterion_main; + +mod get_field; +#[path = "../helper.rs"] +mod helper; +mod nullif; +mod overlay; +mod upper; + +criterion_main!( + get_field::benches, + nullif::benches, + overlay::benches, + upper::benches, +); diff --git a/datafusion/functions/benches/nullif.rs b/datafusion/functions/benches/misc/nullif.rs similarity index 96% rename from datafusion/functions/benches/nullif.rs rename to datafusion/functions/benches/misc/nullif.rs index f9f063c52d0d4..ad111ad25c1c8 100644 --- a/datafusion/functions/benches/nullif.rs +++ b/datafusion/functions/benches/misc/nullif.rs @@ -17,7 +17,7 @@ use arrow::datatypes::{DataType, Field}; use arrow::util::bench_util::create_string_array_with_len; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -61,4 +61,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/overlay.rs b/datafusion/functions/benches/misc/overlay.rs similarity index 97% rename from datafusion/functions/benches/overlay.rs rename to datafusion/functions/benches/misc/overlay.rs index 0b7fff5989d1f..f4e4a85a181e8 100644 --- a/datafusion/functions/benches/overlay.rs +++ b/datafusion/functions/benches/misc/overlay.rs @@ -15,14 +15,12 @@ // specific language governing permissions and limitations // under the License. -mod helper; - +use crate::helper::gen_string_array; use arrow::datatypes::{DataType, Field}; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs, ScalarUDF}; -use helper::gen_string_array; use std::hint::black_box; use std::sync::Arc; @@ -197,4 +195,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/upper.rs b/datafusion/functions/benches/misc/upper.rs similarity index 96% rename from datafusion/functions/benches/upper.rs rename to datafusion/functions/benches/misc/upper.rs index 3f6fa36b18c13..19415471555ca 100644 --- a/datafusion/functions/benches/upper.rs +++ b/datafusion/functions/benches/misc/upper.rs @@ -17,7 +17,7 @@ use arrow::datatypes::{DataType, Field}; use arrow::util::bench_util::create_string_array_with_len; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; use datafusion_functions::string; @@ -55,4 +55,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/regex_expressions/main.rs b/datafusion/functions/benches/regex_expressions/main.rs new file mode 100644 index 0000000000000..6ef9694a04e8e --- /dev/null +++ b/datafusion/functions/benches/regex_expressions/main.rs @@ -0,0 +1,38 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! Benchmarks for functions behind the `regex_expressions` feature. +//! +//! Each benchmark beside this file is a module rather than its own `[[bench]]` +//! target: a separate target per benchmark means a separate binary to link, +//! which dominated the cost of building this crate's benchmarks. +//! +//! Run one of them with `cargo bench --bench regex_expressions -- `. + +use criterion::criterion_main; + +mod regexp_count; +mod regexp_instr; +mod regexp_match; +mod regx; + +criterion_main!( + regexp_count::benches, + regexp_instr::benches, + regexp_match::benches, + regx::benches, +); diff --git a/datafusion/functions/benches/regexp_count.rs b/datafusion/functions/benches/regex_expressions/regexp_count.rs similarity index 97% rename from datafusion/functions/benches/regexp_count.rs rename to datafusion/functions/benches/regex_expressions/regexp_count.rs index bce76c05585b9..b489046779fa3 100644 --- a/datafusion/functions/benches/regexp_count.rs +++ b/datafusion/functions/benches/regex_expressions/regexp_count.rs @@ -19,7 +19,7 @@ use arrow::array::Int64Array; use arrow::array::OffsetSizeTrait; use arrow::datatypes::{DataType, Field}; use arrow::util::bench_util::create_string_array_with_len; -use criterion::{Criterion, SamplingMode, criterion_group, criterion_main}; +use criterion::{Criterion, SamplingMode, criterion_group}; use datafusion_common::config::ConfigOptions; use datafusion_common::{DataFusionError, ScalarValue}; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -113,4 +113,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/regexp_instr.rs b/datafusion/functions/benches/regex_expressions/regexp_instr.rs similarity index 97% rename from datafusion/functions/benches/regexp_instr.rs rename to datafusion/functions/benches/regex_expressions/regexp_instr.rs index 9ac630d8c4b6e..d41723f29ebf1 100644 --- a/datafusion/functions/benches/regexp_instr.rs +++ b/datafusion/functions/benches/regex_expressions/regexp_instr.rs @@ -19,7 +19,7 @@ use arrow::array::Int64Array; use arrow::array::OffsetSizeTrait; use arrow::datatypes::{DataType, Field}; use arrow::util::bench_util::create_string_array_with_len; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::config::ConfigOptions; use datafusion_common::{DataFusionError, ScalarValue}; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -96,4 +96,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/regexp_match.rs b/datafusion/functions/benches/regex_expressions/regexp_match.rs similarity index 98% rename from datafusion/functions/benches/regexp_match.rs rename to datafusion/functions/benches/regex_expressions/regexp_match.rs index d5929df07c81f..b36fbebc92a20 100644 --- a/datafusion/functions/benches/regexp_match.rs +++ b/datafusion/functions/benches/regex_expressions/regexp_match.rs @@ -25,7 +25,7 @@ use std::sync::Arc; use arrow::array::{ArrayRef, StringArray}; use arrow::compute::cast; use arrow::datatypes::{DataType, Field}; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs, ScalarUDFImpl}; @@ -134,4 +134,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/regx.rs b/datafusion/functions/benches/regex_expressions/regx.rs similarity index 99% rename from datafusion/functions/benches/regx.rs rename to datafusion/functions/benches/regex_expressions/regx.rs index dd263e41f6fc5..09b7f9acb7469 100644 --- a/datafusion/functions/benches/regx.rs +++ b/datafusion/functions/benches/regex_expressions/regx.rs @@ -23,7 +23,7 @@ use arrow::array::builder::StringBuilder; use arrow::array::{ArrayRef, AsArray, Int64Array, StringArray, StringViewArray}; use arrow::compute::cast; use arrow::datatypes::{DataType, Field}; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs, ScalarUDFImpl}; @@ -331,4 +331,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/ascii.rs b/datafusion/functions/benches/string_expressions/ascii.rs similarity index 98% rename from datafusion/functions/benches/ascii.rs rename to datafusion/functions/benches/string_expressions/ascii.rs index a2424ed352afc..030ae11199a84 100644 --- a/datafusion/functions/benches/ascii.rs +++ b/datafusion/functions/benches/string_expressions/ascii.rs @@ -15,14 +15,12 @@ // specific language governing permissions and limitations // under the License. -mod helper; - +use crate::helper::gen_string_array; use arrow::datatypes::{DataType, Field}; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; -use helper::gen_string_array; use std::hint::black_box; use std::sync::Arc; @@ -165,4 +163,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/chr.rs b/datafusion/functions/benches/string_expressions/chr.rs similarity index 97% rename from datafusion/functions/benches/chr.rs rename to datafusion/functions/benches/string_expressions/chr.rs index a702dc161ae06..d7968605f62ef 100644 --- a/datafusion/functions/benches/chr.rs +++ b/datafusion/functions/benches/string_expressions/chr.rs @@ -16,7 +16,7 @@ // under the License. use arrow::{array::PrimitiveArray, datatypes::Int64Type}; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; use datafusion_functions::string::chr; @@ -96,4 +96,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/concat.rs b/datafusion/functions/benches/string_expressions/concat.rs similarity index 98% rename from datafusion/functions/benches/concat.rs rename to datafusion/functions/benches/string_expressions/concat.rs index 6736625be0365..4736ca1542209 100644 --- a/datafusion/functions/benches/concat.rs +++ b/datafusion/functions/benches/string_expressions/concat.rs @@ -18,7 +18,7 @@ use arrow::array::ArrayRef; use arrow::datatypes::{DataType, Field}; use arrow::util::bench_util::{create_string_array_with_len, create_string_view_array}; -use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main}; +use criterion::{BenchmarkId, Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -168,4 +168,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/concat_ws.rs b/datafusion/functions/benches/string_expressions/concat_ws.rs similarity index 97% rename from datafusion/functions/benches/concat_ws.rs rename to datafusion/functions/benches/string_expressions/concat_ws.rs index d437f38773f78..c4c809a1e451e 100644 --- a/datafusion/functions/benches/concat_ws.rs +++ b/datafusion/functions/benches/string_expressions/concat_ws.rs @@ -18,7 +18,7 @@ use arrow::array::ArrayRef; use arrow::datatypes::{DataType, Field}; use arrow::util::bench_util::create_string_array_with_len; -use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main}; +use criterion::{BenchmarkId, Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -120,4 +120,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/contains.rs b/datafusion/functions/benches/string_expressions/contains.rs similarity index 98% rename from datafusion/functions/benches/contains.rs rename to datafusion/functions/benches/string_expressions/contains.rs index 6c39f45e14fa6..7b7ca824c3010 100644 --- a/datafusion/functions/benches/contains.rs +++ b/datafusion/functions/benches/string_expressions/contains.rs @@ -17,7 +17,7 @@ use arrow::array::{StringArray, StringViewArray}; use arrow::datatypes::{DataType, Field}; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -180,4 +180,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/ends_with.rs b/datafusion/functions/benches/string_expressions/ends_with.rs similarity index 98% rename from datafusion/functions/benches/ends_with.rs rename to datafusion/functions/benches/string_expressions/ends_with.rs index 474e8a1555cf2..35ce196149788 100644 --- a/datafusion/functions/benches/ends_with.rs +++ b/datafusion/functions/benches/string_expressions/ends_with.rs @@ -17,7 +17,7 @@ use arrow::array::{StringArray, StringViewArray}; use arrow::datatypes::{DataType, Field}; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -180,4 +180,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/lower.rs b/datafusion/functions/benches/string_expressions/lower.rs similarity index 99% rename from datafusion/functions/benches/lower.rs rename to datafusion/functions/benches/string_expressions/lower.rs index 2764491c69c71..2f7310615741d 100644 --- a/datafusion/functions/benches/lower.rs +++ b/datafusion/functions/benches/string_expressions/lower.rs @@ -20,7 +20,7 @@ use arrow::datatypes::{DataType, Field}; use arrow::util::bench_util::{ create_string_array_with_len, create_string_view_array_with_len, }; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; use datafusion_functions::string; @@ -301,4 +301,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/string_expressions/main.rs b/datafusion/functions/benches/string_expressions/main.rs new file mode 100644 index 0000000000000..17cfe27e497e0 --- /dev/null +++ b/datafusion/functions/benches/string_expressions/main.rs @@ -0,0 +1,64 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! Benchmarks for functions behind the `string_expressions` feature. +//! +//! Each benchmark beside this file is a module rather than its own `[[bench]]` +//! target: a separate target per benchmark means a separate binary to link, +//! which dominated the cost of building this crate's benchmarks. +//! +//! Run one of them with `cargo bench --bench string_expressions -- `. + +use criterion::criterion_main; + +mod ascii; +mod chr; +mod concat; +mod concat_ws; +mod contains; +mod ends_with; +#[path = "../helper.rs"] +mod helper; +mod lower; +mod repeat; +mod replace; +mod replace_scalar; +mod split_part; +mod starts_with; +mod to_hex; +mod trim; +mod upper_unicode; +mod uuid; + +criterion_main!( + ascii::benches, + chr::benches, + concat::benches, + concat_ws::benches, + contains::benches, + ends_with::benches, + lower::benches, + repeat::benches, + replace::benches, + replace_scalar::benches, + split_part::benches, + starts_with::benches, + to_hex::benches, + trim::benches, + upper_unicode::benches, + uuid::benches, +); diff --git a/datafusion/functions/benches/repeat.rs b/datafusion/functions/benches/string_expressions/repeat.rs similarity index 98% rename from datafusion/functions/benches/repeat.rs rename to datafusion/functions/benches/string_expressions/repeat.rs index 354812c0d2ea2..faa4953838da9 100644 --- a/datafusion/functions/benches/repeat.rs +++ b/datafusion/functions/benches/string_expressions/repeat.rs @@ -20,7 +20,7 @@ use arrow::datatypes::{DataType, Field}; use arrow::util::bench_util::{ create_string_array_with_len, create_string_view_array_with_len, }; -use criterion::{Criterion, SamplingMode, criterion_group, criterion_main}; +use criterion::{Criterion, SamplingMode, criterion_group}; use datafusion_common::DataFusionError; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; @@ -225,4 +225,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/replace.rs b/datafusion/functions/benches/string_expressions/replace.rs similarity index 98% rename from datafusion/functions/benches/replace.rs rename to datafusion/functions/benches/string_expressions/replace.rs index 7ad198995a028..71d33f99f14bb 100644 --- a/datafusion/functions/benches/replace.rs +++ b/datafusion/functions/benches/string_expressions/replace.rs @@ -20,7 +20,7 @@ use arrow::datatypes::{DataType, Field}; use arrow::util::bench_util::{ create_string_array_with_len, create_string_view_array_with_len, }; -use criterion::{Criterion, SamplingMode, criterion_group, criterion_main}; +use criterion::{Criterion, SamplingMode, criterion_group}; use datafusion_common::DataFusionError; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -167,4 +167,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/replace_scalar.rs b/datafusion/functions/benches/string_expressions/replace_scalar.rs similarity index 97% rename from datafusion/functions/benches/replace_scalar.rs rename to datafusion/functions/benches/string_expressions/replace_scalar.rs index e64c12e8ebf40..f0d90f43be305 100644 --- a/datafusion/functions/benches/replace_scalar.rs +++ b/datafusion/functions/benches/string_expressions/replace_scalar.rs @@ -21,7 +21,7 @@ use arrow::array::ArrayRef; use arrow::datatypes::{DataType, Field}; use arrow::util::bench_util::create_string_array_with_len; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -75,4 +75,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/split_part.rs b/datafusion/functions/benches/string_expressions/split_part.rs similarity index 98% rename from datafusion/functions/benches/split_part.rs rename to datafusion/functions/benches/string_expressions/split_part.rs index d578339368768..910814d8e3153 100644 --- a/datafusion/functions/benches/split_part.rs +++ b/datafusion/functions/benches/string_expressions/split_part.rs @@ -17,7 +17,7 @@ use arrow::array::{ArrayRef, Int64Array, StringArray, StringViewArray}; use arrow::datatypes::{DataType, Field}; -use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main}; +use criterion::{BenchmarkId, Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs, ScalarUDF}; @@ -269,4 +269,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/starts_with.rs b/datafusion/functions/benches/string_expressions/starts_with.rs similarity index 98% rename from datafusion/functions/benches/starts_with.rs rename to datafusion/functions/benches/string_expressions/starts_with.rs index 17483f0da7a07..24c22864fd299 100644 --- a/datafusion/functions/benches/starts_with.rs +++ b/datafusion/functions/benches/string_expressions/starts_with.rs @@ -17,7 +17,7 @@ use arrow::array::{StringArray, StringViewArray}; use arrow::datatypes::{DataType, Field}; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -180,4 +180,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/to_hex.rs b/datafusion/functions/benches/string_expressions/to_hex.rs similarity index 98% rename from datafusion/functions/benches/to_hex.rs rename to datafusion/functions/benches/string_expressions/to_hex.rs index 33f8d9c49e8eb..debf915abee75 100644 --- a/datafusion/functions/benches/to_hex.rs +++ b/datafusion/functions/benches/string_expressions/to_hex.rs @@ -18,7 +18,7 @@ use arrow::array::Int64Array; use arrow::datatypes::{DataType, Field, Int32Type, Int64Type}; use arrow::util::bench_util::create_primitive_array; -use criterion::{Criterion, SamplingMode, criterion_group, criterion_main}; +use criterion::{Criterion, SamplingMode, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -151,4 +151,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/trim.rs b/datafusion/functions/benches/string_expressions/trim.rs similarity index 98% rename from datafusion/functions/benches/trim.rs rename to datafusion/functions/benches/string_expressions/trim.rs index 21d99592d1820..9970cf2f8064a 100644 --- a/datafusion/functions/benches/trim.rs +++ b/datafusion/functions/benches/string_expressions/trim.rs @@ -18,8 +18,7 @@ use arrow::array::{ArrayRef, LargeStringArray, StringArray, StringViewArray}; use arrow::datatypes::{DataType, Field}; use criterion::{ - BenchmarkGroup, Criterion, SamplingMode, criterion_group, criterion_main, - measurement::Measurement, + BenchmarkGroup, Criterion, SamplingMode, criterion_group, measurement::Measurement, }; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; @@ -432,4 +431,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/upper_unicode.rs b/datafusion/functions/benches/string_expressions/upper_unicode.rs similarity index 97% rename from datafusion/functions/benches/upper_unicode.rs rename to datafusion/functions/benches/string_expressions/upper_unicode.rs index 2748c85e74854..9243da2912260 100644 --- a/datafusion/functions/benches/upper_unicode.rs +++ b/datafusion/functions/benches/string_expressions/upper_unicode.rs @@ -23,7 +23,7 @@ use std::sync::Arc; use arrow::array::{ArrayRef, LargeStringArray, StringArray}; use arrow::datatypes::{DataType, Field}; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs, ScalarUDF}; use datafusion_functions::string; @@ -87,4 +87,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/uuid.rs b/datafusion/functions/benches/string_expressions/uuid.rs similarity index 94% rename from datafusion/functions/benches/uuid.rs rename to datafusion/functions/benches/string_expressions/uuid.rs index 629fb950dd9ff..47a3412a35ebc 100644 --- a/datafusion/functions/benches/uuid.rs +++ b/datafusion/functions/benches/string_expressions/uuid.rs @@ -16,7 +16,7 @@ // under the License. use arrow::datatypes::{DataType, Field}; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::config::ConfigOptions; use datafusion_expr::ScalarFunctionArgs; use datafusion_functions::string; @@ -41,4 +41,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/character_length.rs b/datafusion/functions/benches/unicode_expressions/character_length.rs similarity index 97% rename from datafusion/functions/benches/character_length.rs rename to datafusion/functions/benches/unicode_expressions/character_length.rs index 4927627ec2f05..3aac173c60988 100644 --- a/datafusion/functions/benches/character_length.rs +++ b/datafusion/functions/benches/unicode_expressions/character_length.rs @@ -15,16 +15,14 @@ // specific language governing permissions and limitations // under the License. +use crate::helper::gen_string_array; use arrow::datatypes::{DataType, Field}; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::config::ConfigOptions; use datafusion_expr::ScalarFunctionArgs; -use helper::gen_string_array; use std::hint::black_box; use std::sync::Arc; -mod helper; - fn criterion_benchmark(c: &mut Criterion) { // All benches are single batch run with 8192 rows let character_length = datafusion_functions::unicode::character_length(); @@ -133,4 +131,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/find_in_set.rs b/datafusion/functions/benches/unicode_expressions/find_in_set.rs similarity index 98% rename from datafusion/functions/benches/find_in_set.rs rename to datafusion/functions/benches/unicode_expressions/find_in_set.rs index 9ee20ecd14fdf..9898ab5501ab6 100644 --- a/datafusion/functions/benches/find_in_set.rs +++ b/datafusion/functions/benches/unicode_expressions/find_in_set.rs @@ -20,7 +20,7 @@ use arrow::datatypes::{DataType, Field}; use arrow::util::bench_util::{ create_string_array_with_len, create_string_view_array_with_len, }; -use criterion::{Criterion, SamplingMode, criterion_group, criterion_main}; +use criterion::{Criterion, SamplingMode, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -235,4 +235,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/find_in_set_literal.rs b/datafusion/functions/benches/unicode_expressions/find_in_set_literal.rs similarity index 97% rename from datafusion/functions/benches/find_in_set_literal.rs rename to datafusion/functions/benches/unicode_expressions/find_in_set_literal.rs index 013c7c2081668..96ff370889b27 100644 --- a/datafusion/functions/benches/find_in_set_literal.rs +++ b/datafusion/functions/benches/unicode_expressions/find_in_set_literal.rs @@ -21,7 +21,7 @@ use arrow::array::StringArray; use arrow::datatypes::{DataType, Field}; -use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main}; +use criterion::{BenchmarkId, Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -95,4 +95,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/initcap.rs b/datafusion/functions/benches/unicode_expressions/initcap.rs similarity index 98% rename from datafusion/functions/benches/initcap.rs rename to datafusion/functions/benches/unicode_expressions/initcap.rs index b5e653e4136a3..81340ac150947 100644 --- a/datafusion/functions/benches/initcap.rs +++ b/datafusion/functions/benches/unicode_expressions/initcap.rs @@ -20,7 +20,7 @@ use arrow::datatypes::{DataType, Field}; use arrow::util::bench_util::{ create_string_array_with_len, create_string_view_array_with_len, }; -use criterion::{Criterion, SamplingMode, criterion_group, criterion_main}; +use criterion::{Criterion, SamplingMode, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -206,4 +206,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/left_right.rs b/datafusion/functions/benches/unicode_expressions/left_right.rs similarity index 97% rename from datafusion/functions/benches/left_right.rs rename to datafusion/functions/benches/unicode_expressions/left_right.rs index 8d5865acb845e..01a0dcad6990b 100644 --- a/datafusion/functions/benches/left_right.rs +++ b/datafusion/functions/benches/unicode_expressions/left_right.rs @@ -24,7 +24,7 @@ use arrow::datatypes::{DataType, Field}; use arrow::util::bench_util::{ create_string_array_with_len, create_string_view_array_with_len, }; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; use datafusion_functions::unicode::{left, right}; @@ -112,4 +112,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/levenshtein.rs b/datafusion/functions/benches/unicode_expressions/levenshtein.rs similarity index 96% rename from datafusion/functions/benches/levenshtein.rs rename to datafusion/functions/benches/unicode_expressions/levenshtein.rs index 08733b245ffb4..f29af186ec94f 100644 --- a/datafusion/functions/benches/levenshtein.rs +++ b/datafusion/functions/benches/unicode_expressions/levenshtein.rs @@ -18,7 +18,7 @@ use arrow::array::OffsetSizeTrait; use arrow::datatypes::{DataType, Field}; use arrow::util::bench_util::create_string_array_with_len; -use criterion::{Criterion, SamplingMode, criterion_group, criterion_main}; +use criterion::{Criterion, SamplingMode, criterion_group}; use datafusion_common::DataFusionError; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -82,4 +82,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/unicode_expressions/main.rs b/datafusion/functions/benches/unicode_expressions/main.rs new file mode 100644 index 0000000000000..f79920e78b2ee --- /dev/null +++ b/datafusion/functions/benches/unicode_expressions/main.rs @@ -0,0 +1,56 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! Benchmarks for functions behind the `unicode_expressions` feature. +//! +//! Each benchmark beside this file is a module rather than its own `[[bench]]` +//! target: a separate target per benchmark means a separate binary to link, +//! which dominated the cost of building this crate's benchmarks. +//! +//! Run one of them with `cargo bench --bench unicode_expressions -- `. + +use criterion::criterion_main; + +mod character_length; +mod find_in_set; +mod find_in_set_literal; +#[path = "../helper.rs"] +mod helper; +mod initcap; +mod left_right; +mod levenshtein; +mod pad; +mod reverse; +mod strpos; +mod substr; +mod substr_index; +mod translate; + +criterion_main!( + character_length::benches, + find_in_set::benches, + find_in_set_literal::benches, + initcap::benches, + left_right::benches, + levenshtein::benches, + pad::benches, + reverse::benches, + strpos::benches, + substr::benches, + substr_index::benches, + translate::benches, +); diff --git a/datafusion/functions/benches/pad.rs b/datafusion/functions/benches/unicode_expressions/pad.rs similarity index 99% rename from datafusion/functions/benches/pad.rs rename to datafusion/functions/benches/unicode_expressions/pad.rs index 78ebf12236a70..b7662033834dd 100644 --- a/datafusion/functions/benches/pad.rs +++ b/datafusion/functions/benches/unicode_expressions/pad.rs @@ -23,7 +23,7 @@ use arrow::datatypes::{DataType, Field, Int64Type}; use arrow::util::bench_util::{ create_string_array_with_len, create_string_view_array_with_len, }; -use criterion::{Criterion, SamplingMode, criterion_group, criterion_main}; +use criterion::{Criterion, SamplingMode, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -758,4 +758,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/reverse.rs b/datafusion/functions/benches/unicode_expressions/reverse.rs similarity index 97% rename from datafusion/functions/benches/reverse.rs rename to datafusion/functions/benches/unicode_expressions/reverse.rs index f2e2898bbfe43..8e7a5592b9bf6 100644 --- a/datafusion/functions/benches/reverse.rs +++ b/datafusion/functions/benches/unicode_expressions/reverse.rs @@ -15,13 +15,11 @@ // specific language governing permissions and limitations // under the License. -mod helper; - +use crate::helper::gen_string_array; use arrow::datatypes::{DataType, Field}; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::config::ConfigOptions; use datafusion_expr::ScalarFunctionArgs; -use helper::gen_string_array; use std::hint::black_box; use std::sync::Arc; @@ -138,4 +136,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/strpos.rs b/datafusion/functions/benches/unicode_expressions/strpos.rs similarity index 98% rename from datafusion/functions/benches/strpos.rs rename to datafusion/functions/benches/unicode_expressions/strpos.rs index 549186dbab14d..2902d41df6fc2 100644 --- a/datafusion/functions/benches/strpos.rs +++ b/datafusion/functions/benches/unicode_expressions/strpos.rs @@ -17,7 +17,7 @@ use arrow::array::{StringArray, StringViewArray}; use arrow::datatypes::{DataType, Field}; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::ScalarValue; use datafusion_common::config::ConfigOptions; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -232,4 +232,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/substr.rs b/datafusion/functions/benches/unicode_expressions/substr.rs similarity index 99% rename from datafusion/functions/benches/substr.rs rename to datafusion/functions/benches/unicode_expressions/substr.rs index 3939fd100e459..c98c7d99c2706 100644 --- a/datafusion/functions/benches/substr.rs +++ b/datafusion/functions/benches/unicode_expressions/substr.rs @@ -20,7 +20,7 @@ use arrow::datatypes::{DataType, Field}; use arrow::util::bench_util::{ create_string_array_with_len, create_string_view_array_with_len, }; -use criterion::{Criterion, SamplingMode, criterion_group, criterion_main}; +use criterion::{Criterion, SamplingMode, criterion_group}; use datafusion_common::config::ConfigOptions; use datafusion_common::{DataFusionError, ScalarValue}; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -291,4 +291,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/substr_index.rs b/datafusion/functions/benches/unicode_expressions/substr_index.rs similarity index 99% rename from datafusion/functions/benches/substr_index.rs rename to datafusion/functions/benches/unicode_expressions/substr_index.rs index a0c3784dbeee5..fb5e77cfa07b4 100644 --- a/datafusion/functions/benches/substr_index.rs +++ b/datafusion/functions/benches/unicode_expressions/substr_index.rs @@ -20,7 +20,7 @@ use std::sync::Arc; use arrow::array::{ArrayRef, Int64Array, StringArray, StringViewArray}; use arrow::datatypes::{DataType, Field}; -use criterion::{Criterion, criterion_group, criterion_main}; +use criterion::{Criterion, criterion_group}; use datafusion_common::{ScalarValue, config::ConfigOptions}; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; use datafusion_functions::unicode::substr_index; @@ -257,4 +257,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/datafusion/functions/benches/translate.rs b/datafusion/functions/benches/unicode_expressions/translate.rs similarity index 98% rename from datafusion/functions/benches/translate.rs rename to datafusion/functions/benches/unicode_expressions/translate.rs index adde7b4bd763d..90fdf4970fbf6 100644 --- a/datafusion/functions/benches/translate.rs +++ b/datafusion/functions/benches/unicode_expressions/translate.rs @@ -18,7 +18,7 @@ use arrow::array::{GenericStringArray, OffsetSizeTrait}; use arrow::datatypes::{DataType, Field}; use arrow::util::bench_util::create_string_array_with_len; -use criterion::{Criterion, SamplingMode, criterion_group, criterion_main}; +use criterion::{Criterion, SamplingMode, criterion_group}; use datafusion_common::config::ConfigOptions; use datafusion_common::{DataFusionError, ScalarValue}; use datafusion_expr::{ColumnarValue, ScalarFunctionArgs}; @@ -162,4 +162,3 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches);