Development tools to help you figure out the performance of your code.
Flame graphs are excellent for visualizing CPU usage and identifying hot spots. System profilers like perf provide more detailed information. Benchmarking helps you measure the impact of code changes. Memory profilers help you find memory leaks and excessive allocations. Tracing helps you understand the flow of your program.
Topic
Rust Crates
Flame Graphs
cargo flamegraph generates flame graphs from Rust programs.
System Profilers (In-depth Analysis)
perf⮳ is a powerful system profiler for Linux. cargo flamegraph often uses perf under the hood. dtrace⮳ is another system profiler for macOS, BSD. VTune (Intel) is a commercial profiler.
Benchmarking
Built-in cargo bench allows you to write benchmarks directly in your Rust code.
In-Code Profiling (Specific Code Regions)
measure_time⮳ is a simple crate for measuring the execution time of code blocks.
Memory Profiling
valgrind⮳ (with massif or memcheck): While not Rust-specific, Valgrind is a powerful tool for memory profiling and leak detection. You'd run your Rust program under Valgrind.
Tracing - Understanding Program Flow
tracing⮳: While not strictly a profiler in the performance sense, tracing⮳ allows you to instrument your code with spans and events, which can be invaluable for understanding the flow of execution and identifying bottlenecks. Often used in combination with other profiling tools.
Sampling Profilers (CPU Usage)
samply⮳ is a native sampling profiler focusing on ease of use. callgrind⮳ is a performance analysis tool often used with kcachegrind for visualization.