diff --git a/src/uu/sort/BENCHMARKING.md b/src/uu/sort/BENCHMARKING.md index 1caea0326..1810e8a4e 100644 --- a/src/uu/sort/BENCHMARKING.md +++ b/src/uu/sort/BENCHMARKING.md @@ -69,6 +69,12 @@ Run `cargo build --release` before benchmarking after you make a change! - Benchmark numeric sorting with hyperfine: `hyperfine "target/release/coreutils sort shuffled_numbers_si.txt -h -o output.txt"`. +## External sorting + +Try running commands with the `-S` option set to an amount of memory to be used, such as `1M`. Additionally, you could try sorting +huge files (ideally multiple Gigabytes) with `-S`. Creating such a large file can be achieved by running `cat shuffled_wordlist.txt | sort -R >> shuffled_wordlist.txt` +multiple times (this will add the contents of `shuffled_wordlist.txt` to itself). + ## Stdout and stdin performance Try to run the above benchmarks by piping the input through stdin (standard input) and redirect the diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index 7c053e4ad..be7944a0f 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -1169,9 +1169,7 @@ fn file_to_lines_iter<'a>( }) .map(move |line| { Line::new( - std::str::from_utf8(&line.unwrap()) - .expect("input is not valid utf-8") - .to_string(), + crash_if_err!(1, String::from_utf8(crash_if_err!(1, line))), settings, ) }), @@ -1226,7 +1224,7 @@ fn exec(files: Vec, settings: GlobalSettings) -> i32 { } else { b'\n' }) { - let string = String::from_utf8(line.unwrap()).unwrap(); + let string = crash_if_err!(1, String::from_utf8(crash_if_err!(1, line))); lines.push(Line::new(string, &settings)); } }