From d26ff9761b608def2a7004953c719eb96b3c1c2d Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 26 Oct 2025 13:53:28 +0100 Subject: [PATCH] bench: remove 'sort_random_strings' --- src/uu/sort/benches/sort_locale_bench.rs | 20 -------------------- src/uucore/src/lib/features/benchmark.rs | 19 ------------------- 2 files changed, 39 deletions(-) diff --git a/src/uu/sort/benches/sort_locale_bench.rs b/src/uu/sort/benches/sort_locale_bench.rs index d6a60effb8d..d00ec9f4ac8 100644 --- a/src/uu/sort/benches/sort_locale_bench.rs +++ b/src/uu/sort/benches/sort_locale_bench.rs @@ -129,26 +129,6 @@ fn sort_german_locale(bencher: Bencher) { }); } -/// Benchmark random strings of different lengths -#[divan::bench] -fn sort_random_strings(bencher: Bencher) { - let data = text_data::generate_random_strings(50_000, 50); - let file_path = setup_test_file(&data); - // Reuse the same output file across iterations to reduce filesystem variance - let output_file = NamedTempFile::new().unwrap(); - let output_path = output_file.path().to_str().unwrap().to_string(); - - bencher.bench(|| { - unsafe { - env::set_var("LC_ALL", "en_US.UTF-8"); - } - black_box(run_util_function( - uumain, - &["-o", &output_path, file_path.to_str().unwrap()], - )); - }); -} - /// Benchmark numeric sorting performance #[divan::bench] fn sort_numeric(bencher: Bencher) { diff --git a/src/uucore/src/lib/features/benchmark.rs b/src/uucore/src/lib/features/benchmark.rs index 0ca60d2d772..306ffdc3da7 100644 --- a/src/uucore/src/lib/features/benchmark.rs +++ b/src/uucore/src/lib/features/benchmark.rs @@ -280,25 +280,6 @@ pub mod text_data { generate_data_from_words_simple(&base_words, num_lines) } - /// Generate random strings with mixed charset including accented characters - pub fn generate_random_strings(num_lines: usize, length: usize) -> Vec { - let mut data = Vec::new(); - let charset = - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789äöüÄÖÜßéèêëàâîïôûç"; - let charset_bytes = charset.as_bytes(); - - for i in 0..num_lines { - let mut line = String::new(); - for j in 0..length { - let idx = ((i * length + j) * 17 + 42) % charset_bytes.len(); - line.push(charset_bytes[idx] as char); - } - line.push('\n'); - data.extend_from_slice(line.as_bytes()); - } - data - } - /// Generate numeric data for benchmarking (simple sequential numbers) pub fn generate_numbers(count: usize) -> String { (1..=count)