echo: add benchmark (#12091)

This commit is contained in:
oech3
2026-05-17 06:04:04 +09:00
committed by GitHub
parent 454832b2d9
commit 8db2277257
4 changed files with 32 additions and 0 deletions
+1
View File
@@ -36,6 +36,7 @@ jobs:
uu_dd,
uu_df,
uu_du,
uu_echo,
uu_expand,
uu_fold,
uu_hostname,
Generated
+1
View File
@@ -3485,6 +3485,7 @@ name = "uu_echo"
version = "0.8.0"
dependencies = [
"clap",
"codspeed-divan-compat",
"fluent",
"uucore",
]
+8
View File
@@ -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
+22
View File
@@ -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();
}