Valgrind

Let's first start with a tool that will help you find where your software spends more time. Valgrind is a tool that helps to find bottlenecks. Two main tools inside Valgrind will give us the statistics we need to find out where to improve our code. It's included in most Linux distributions. There are Windows alternatives, but if you have access to a Linux machine (even if it's a virtual one), Valgrind will really make the difference when getting results.

The easiest way to use it is to use cargo-profiler. This tool is in crates.io, but it's no longer updated, and the version in GitHub has some much-needed fixes. You can install it by running the following command:

cargo install --git https://github.com/kernelmachine/cargo-profiler.git ...

Get Rust High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.