Hyperfine is a command-line benchmarking tool. It runs an analysis across multiple runs, has support for arbitrary shell commands, and can export results to various formats.
USE flags for app-benchmarks/hyperfine A command-line benchmarking tool (runs other benchmarks)
|Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces
emerge --ask app-benchmarks/hyperfine
The simplest benchmark you can run is likely the
sleep command. For example:
hyperfine 'sleep 0.3'
Warmup runs will likely come in handy if you are running a program that is I/O intensive, like grep. This is because benchmarks can be heavily influenced by whether the disk caches are warm or cold.
If you wish to benchmark for a warm cache, you can run
hyperfine --warmup 3 'grep -R TODO *'
For cold caches, you can use the
--prepare option to run a special command before each timing run.
hyperfine --prepare 'sync; echo 3 | sudo tee /proc/sys/vm/drop_caches' 'grep -R TODO *'
You can export hyperfine results to a various amount of formats, for markdown you would use
--export-markdown <file> to create a table of the results.
The JSON output is more detailed and can be used in plotting charts.