Prerequisites

In order to use Iai-Callgrind, you must have Valgrind installed. This means that Iai-Callgrind cannot be used on platforms that are not supported by Valgrind.

The default benchmarking tool is Callgrind and is in most cases perfectly suited to do the job but if you want or need to use Cachegrind instead of Callgrind you require valgrind version >= 3.22 and client requests (see below).

Debug Symbols

It's required to run the Iai-Callgrind benchmarks with debugging symbols switched on. For example in your ~/.cargo/config or your project's Cargo.toml:

[profile.bench]
debug = true

Now, all benchmarks which are run with cargo bench include the debug symbols. (See also Cargo Profiles and Cargo Config).

It's required that settings like strip = true or other configuration options stripping the debug symbols need to be disabled explicitly for the bench profile if you have changed this option for the release profile. For example:

[profile.release]
strip = true

[profile.bench]
debug = true
strip = false

Valgrind Client Requests

If you want to make use of the mighty Valgrind Client Request Mechanism shipped with Iai-Callgrind, you also need libclang (clang >= 5.0) installed. See also the requirements of bindgen and of cc.

More details on the usage and requirements of Valgrind Client Requests in this chapter of the guide.

Installation of Valgrind

Iai-Callgrind is intentionally independent of a specific version of valgrind. However, Iai-Callgrind was only tested with versions of valgrind >= 3.20.0. It is therefore highly recommended to use a recent version of valgrind. Also, if you want or need to, building valgrind from source is usually a straight-forward process. Just make sure the valgrind binary is in your $PATH so that Iai-Callgrind can find it.

Installation of valgrind with your package manager

Alpine Linux

apk add valgrind

Arch Linux

pacman -Sy valgrind

Debian/Ubuntu

apt-get install valgrind

Fedora Linux

dnf install valgrind

FreeBSD

pkg install valgrind

Valgrind is available for the following distributions

Packaging status