diff --git a/src/uu/df/Cargo.toml b/src/uu/df/Cargo.toml index 813ab93a202..eaa9571f9f2 100644 --- a/src/uu/df/Cargo.toml +++ b/src/uu/df/Cargo.toml @@ -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" diff --git a/src/uu/df/benches/df_bench.rs b/src/uu/df/benches/df_bench.rs index b9453dd0c1e..f678f7f7b9a 100644 --- a/src/uu/df/benches/df_bench.rs +++ b/src/uu/df/benches/df_bench.rs @@ -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(); diff --git a/src/uu/sort/benches/sort_locale_c_bench.rs b/src/uu/sort/benches/sort_locale_c_bench.rs index 378a2abb9ac..8335992716c 100644 --- a/src/uu/sort/benches/sort_locale_c_bench.rs +++ b/src/uu/sort/benches/sort_locale_c_bench.rs @@ -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(); diff --git a/src/uu/sort/benches/sort_locale_utf8_bench.rs b/src/uu/sort/benches/sort_locale_utf8_bench.rs index 2885118c091..81e39c8971f 100644 --- a/src/uu/sort/benches/sort_locale_utf8_bench.rs +++ b/src/uu/sort/benches/sort_locale_utf8_bench.rs @@ -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();