created on 2020-08-08, edited on 2020-09-26

Profiling Rust on macOS

It has been some time since I've started to use Rust for my hobby projects. As you know when the projects get more complex, performance may become an issue. Here, I'm writing down the available options for profiling Rust programs on macOS for future reference but I'm sure most of the crates and tools are also usable in other operating systems.

Xcode

This is probably the only option you can find only on macOS. You can use Xcode to get a broad view of how your program behaves. You can see how much CPU time your program takes, how much memory it uses etc.

Go to "All Processes" on the top left of the screen and find your program. Press record and you should see the CPU time your program takes.

pprof

pprof is a very useful tool for profiling your program's CPU footprint.

Using 'criterion'