add benchmarking instructions

This commit is contained in:
Michael Debertol 2021-05-01 17:48:01 +02:00
parent be0c924c95
commit 83554f4475
2 changed files with 8 additions and 4 deletions

View file

@ -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"`. - 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 ## Stdout and stdin performance
Try to run the above benchmarks by piping the input through stdin (standard input) and redirect the Try to run the above benchmarks by piping the input through stdin (standard input) and redirect the

View file

@ -1169,9 +1169,7 @@ fn file_to_lines_iter<'a>(
}) })
.map(move |line| { .map(move |line| {
Line::new( Line::new(
std::str::from_utf8(&line.unwrap()) crash_if_err!(1, String::from_utf8(crash_if_err!(1, line))),
.expect("input is not valid utf-8")
.to_string(),
settings, settings,
) )
}), }),
@ -1226,7 +1224,7 @@ fn exec(files: Vec<String>, settings: GlobalSettings) -> i32 {
} else { } else {
b'\n' 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)); lines.push(Line::new(string, &settings));
} }
} }