diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 1bdb64a047a..20a7987373e 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -35,6 +35,7 @@ jobs: uu_dd, uu_df, uu_du, + uu_echo, uu_expand, uu_fold, uu_hostname, diff --git a/Cargo.lock b/Cargo.lock index ddbc3d42510..c8330e39e4c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3513,6 +3513,7 @@ name = "uu_echo" version = "0.8.0" dependencies = [ "clap", + "codspeed-divan-compat", "fluent", "uucore", ] diff --git a/src/uu/echo/Cargo.toml b/src/uu/echo/Cargo.toml index c17975ac4bc..e23f9176214 100644 --- a/src/uu/echo/Cargo.toml +++ b/src/uu/echo/Cargo.toml @@ -27,3 +27,11 @@ fluent = { workspace = true } [[bin]] name = "echo" path = "src/main.rs" + +[dev-dependencies] +divan = { workspace = true } +uucore = { workspace = true, features = ["benchmark"] } + +[[bench]] +name = "echo_bench" +harness = false diff --git a/src/uu/echo/benches/echo_bench.rs b/src/uu/echo/benches/echo_bench.rs new file mode 100644 index 00000000000..471d4cee3fd --- /dev/null +++ b/src/uu/echo/benches/echo_bench.rs @@ -0,0 +1,22 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. + +use divan::{Bencher, black_box}; +use uu_echo::uumain; +use uucore::benchmark::run_util_function; + +/// Benchmark multiple consecutive invocations +#[divan::bench] +fn echo_consecutive_calls(bencher: Bencher) { + bencher.bench(|| { + for _ in 0..100 { + black_box(run_util_function(uumain, &["Hello World"])); + } + }); +} + +fn main() { + divan::main(); +}