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

Once installed, you can use it by running cargo profiler callgrind or cargo profiler cachegrind, depending on the Valgrind tool you want to use. Nevertheless, cargo-profiler does not compile with source annotations by default, so it might make sense to use the cargo rustc command to compile with a -g flag, and then run Valgrind directly in those binaries:

cargo rustc --release --bin {binary_name} -- -g
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.239.44