Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
uu_shuf,
uu_sort,
uu_split,
uu_timeout,
uu_tsort,
uu_unexpand,
uu_uniq,
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ compare = "0.1.0"
crossterm = "0.29.0"
ctor = "0.6.0"
ctrlc = { version = "3.4.7", features = ["termination"] }
divan = { package = "codspeed-divan-compat", version = "4.0.5" }
divan = { package = "codspeed-divan-compat", version = "4.2.1" }
dns-lookup = { version = "3.0.0" }
exacl = "0.12.0"
file_diff = "1.0.0"
Expand Down
8 changes: 8 additions & 0 deletions src/uu/timeout/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,11 @@ fluent = { workspace = true }
[[bin]]
name = "timeout"
path = "src/main.rs"

[dev-dependencies]
divan = { workspace = true }
uucore = { workspace = true, features = ["benchmark"] }

[[bench]]
name = "timeout_bench"
harness = false
36 changes: 36 additions & 0 deletions src/uu/timeout/benches/timeout_bench.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// 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.

#[cfg(unix)]
use divan::{Bencher, black_box};
#[cfg(unix)]
use uu_timeout::uumain;
#[cfg(unix)]
use uucore::benchmark::run_util_function;

/// Benchmark the fast path where the command exits immediately.

Check failure on line 13 in src/uu/timeout/benches/timeout_bench.rs

View workflow job for this annotation

GitHub Actions / Style and Lint (ubuntu-24.04, unix)

ERROR: `cargo clippy`: empty line after doc comment (file:'src/uu/timeout/benches/timeout_bench.rs', line:13)

Check failure on line 13 in src/uu/timeout/benches/timeout_bench.rs

View workflow job for this annotation

GitHub Actions / Style and Lint (unix)

ERROR: `cargo clippy`: empty line after doc comment (file:'src/uu/timeout/benches/timeout_bench.rs', line:13)
/*
#[cfg(unix)]
#[divan::bench]
fn timeout_quick_exit(bencher: Bencher) {
bencher.bench(|| {
black_box(run_util_function(uumain, &["0.02", "true"]));
});
}
*/

/// Benchmark a command that runs longer than the threshold and receives the default signal.
#[cfg(unix)]
#[divan::bench]
fn timeout_enforced(bencher: Bencher) {
bencher.bench(|| {
black_box(run_util_function(uumain, &["0.02", "sleep", "0.2"]));
});
}

fn main() {
#[cfg(unix)]
divan::main();
}
Loading