Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 6 additions & 3 deletions src/uu/df/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ unicode-width = { workspace = true }
thiserror = { workspace = true }
fluent = { workspace = true }

[target.'cfg(unix)'.dependencies]
rustix = { workspace = true, features = ["fs"] }

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

[target.'cfg(unix)'.dependencies]
rustix = { workspace = true, features = ["fs"] }

[target.'cfg(unix)'.dev-dependencies]
rustix = { workspace = true, features = ["stdio"] }

[[bin]]
name = "df"
path = "src/main.rs"
Expand Down
22 changes: 22 additions & 0 deletions src/uu/df/benches/df_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,28 @@ fn df_deep_directory(bencher: Bencher) {
env::set_current_dir(original_dir).unwrap();
}

#[cfg(unix)]
#[divan::bench]
fn df_with_path(bencher: Bencher) {
use rustix::stdio::dup2_stdout;

let temp_dir = TempDir::new().unwrap();
let temp_path_str = temp_dir.path().to_str().unwrap();
let stdout_bak = rustix::io::dup(rustix::stdio::stdout()).unwrap();
let devnull = fs::OpenOptions::new()
.write(true)
.open("/dev/null")
.unwrap();

bencher.bench_local(|| {
dup2_stdout(&devnull).unwrap();
black_box(run_util_function(uumain, &[temp_path_str]));
});

dup2_stdout(&stdout_bak).unwrap();
}

#[cfg(not(unix))]
#[divan::bench]
fn df_with_path(bencher: Bencher) {
let temp_dir = TempDir::new().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/uu/sort/benches/sort_locale_c_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use uucore::benchmark::{run_util_function, setup_test_file, text_data};
/// Benchmark ASCII-only data sorting with C locale (byte comparison)
#[divan::bench]
fn sort_ascii_c_locale(bencher: Bencher) {
let data = text_data::generate_ascii_data_simple(100_000);
let data = text_data::generate_ascii_data_simple(2_000_000);
let file_path = setup_test_file(&data);
let output_file = NamedTempFile::new().unwrap();
let output_path = output_file.path().to_str().unwrap().to_string();
Expand Down
2 changes: 1 addition & 1 deletion src/uu/sort/benches/sort_locale_utf8_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use uucore::benchmark::{run_util_function, setup_test_file, text_data};
/// Benchmark ASCII-only data sorting with UTF-8 locale
#[divan::bench]
fn sort_ascii_utf8_locale(bencher: Bencher) {
let data = text_data::generate_ascii_data_simple(100_000);
let data = text_data::generate_ascii_data_simple(1_500_000);
let file_path = setup_test_file(&data);
let output_file = NamedTempFile::new().unwrap();
let output_path = output_file.path().to_str().unwrap().to_string();
Expand Down
Loading