Install Hyperfine on Ubuntu 20.04

Install Hyperfine on Ubuntu 20.04

Hyperfine is a tool that enables to benchmark commands. This tool runs command several times and measures execution time of it.

This tutorial demonstrates how to install Hyperfine on Ubuntu 20.04.

Install Hyperfine

Retrieve the latest version tag of Hyperfine release and assign it to variable:

HYPERFINE_VERSION=$(curl -s "" | grep -Po '"tag_name": "v\K[0-9.]+')

Run the following command to download Debian package (.deb) from releases page of the Hyperfine repository:

curl -Lo hyperfine.deb "${HYPERFINE_VERSION}_amd64.deb"

Next, install Hyperfine:

sudo apt install -y ./hyperfine.deb

Once installation is finished, we can check version of Hyperfine:

hyperfine --version

Remove unnecessary .deb package:

rm -rf hyperfine.deb

Testing Hyperfine

To perform a benchmark, run the hyperfine command and give another command as argument.

hyperfine 'sleep 0.5'

By default, Hyperfine runs command at least 10 times and calculates average execution time.

Benchmark sleep command with Hyperfine on Ubuntu

Minimum number of runs for command can be specified with --min-runs option. For example, Hyperfine will perform at least 15 benchmarking runs:

hyperfine --min-runs 15 'sleep 0.5'

Exact number of runs can be specified with --runs option:

hyperfine --runs 7 'sleep 0.5'

Execution time of some commands is limited by disk I/O. Cache can affect benchmarking results. In order to get more accurate results we can use --warmup option to specify number of runs for command before the actual benchmark.

hyperfine --warmup 3 'sudo find / -name *.conf'
Benchmark find command with Hyperfine on Ubuntu

Uninstall Hyperfine

If you want to completely remove Hyperfine, run the following command:

sudo apt purge --autoremove -y hyperfine

Leave a Comment

Cancel reply

Your email address will not be published.