Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
20 changes: 0 additions & 20 deletions src/uu/sort/benches/sort_locale_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
19 changes: 0 additions & 19 deletions src/uucore/src/lib/features/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8> {
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)
Expand Down
Loading