coreutils/src/uu/head/BENCHMARKING.md
Sylvestre Ledru 422a27d375 parent 9d5dc500e6
author Sylvestre Ledru <sylvestre@debian.org> 1677865358 +0100
committer Sylvestre Ledru <sylvestre@debian.org> 1677951797 +0100

md: Fix a bunch of warnings in the docs
2023-03-04 18:43:40 +01:00

1.5 KiB

Benchmarking to measure performance

To compare the performance of the uutils version of head with the GNU version of head, you can use a benchmarking tool like hyperfine. On Ubuntu 18.04 or later, you can install hyperfine by running

sudo apt-get install hyperfine

Next, build the head binary under the release profile:

cargo build --release -p uu_head

Now, get a text file to test head on. I used the Complete Works of William Shakespeare, which is in the public domain in the United States and most other parts of the world.

wget -O shakespeare.txt https://www.gutenberg.org/files/100/100-0.txt

This particular file has about 170,000 lines, each of which is no longer than 96 characters:

$ wc -lL shakespeare.txt
170592      96 shakespeare.txt

You could use files of different shapes and sizes to test the performance of head in different situations. For a larger file, you could download a database dump of Wikidata or some related files that the Wikimedia project provides. For example, this file contains about 130 million lines.

Finally, you can compare the performance of the two versions of head by running, for example,

hyperfine \
    "head -n 100000 shakespeare.txt" \
    "target/release/head -n 100000 shakespeare.txt"