Skip to content

Commit ffbcb4b

Browse files
authored
Merge pull request #8886 from sylvestre/sort-bench
sort: add a bench for long line
2 parents 67d962a + 20a05bd commit ffbcb4b

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

src/uu/sort/benches/sort_bench.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,34 @@ fn sort_unique_locale(bencher: Bencher, num_lines: usize) {
188188
});
189189
}
190190

191+
/// Benchmark sorting with very long lines exceeding START_BUFFER_SIZE (8000 bytes)
192+
#[divan::bench(args = [16_0000])]
193+
fn sort_long_line(bencher: Bencher, line_size: usize) {
194+
// Create files with very long lines (16KB) to test buffer handling
195+
let mut data_a = vec![b'b'; line_size];
196+
data_a.push(b'\n');
197+
198+
let mut data_b = vec![b'a'; line_size];
199+
data_b.push(b'\n');
200+
201+
let file_a = setup_test_file(&data_a);
202+
let file_b = setup_test_file(&data_b);
203+
let output_file = NamedTempFile::new().unwrap();
204+
let output_path = output_file.path().to_str().unwrap();
205+
206+
bencher.bench(|| {
207+
black_box(run_util_function(
208+
uumain,
209+
&[
210+
file_a.to_str().unwrap(),
211+
file_b.to_str().unwrap(),
212+
"-o",
213+
output_path,
214+
],
215+
));
216+
});
217+
}
218+
191219
fn main() {
192220
divan::main();
193221
}

0 commit comments

Comments
 (0)