C++ Profilers
perf, VTune, Tracy, Callgrind, and Orbit — sampling vs. instrumentation, overhead trade-offs, and which to use when.
Quick pick
Comparison matrix
| Property | perf | VTune | Tracy | Callgrind | Orbit |
|---|---|---|---|---|---|
| Method | Sampling | Sampling + Instrumentation | Instrumentation (nanosecond) | Instrumentation (full) | Sampling + Instrumentation |
| Overhead | ~1-3% | ~5-15% | ~1-5% when connected | ~50-100× | ~2-5% |
| GUI | KCachegrind / hotspot | Built-in | Built-in (live + offline) | KCachegrind | Built-in |
| Linux | |||||
| macOS | Limited | ||||
| Windows | |||||
| License | Free / GPL | Free (oneAPI) | Free / BSD | Free / GPL | Free / BSD |
The Linux profiling Swiss-army knife. Hardware counter access, call graphs, cache miss analysis, branch mispredictions.
- Lowest overhead of any Linux profiler
- Hardware PMU counters (cache misses, branch mispredictions, IPC)
- perf stat for quick system-wide stats
- perf record / report for flame graphs
- No instrumentation — works on any binary
- Hotspot GUI for visual flame graphs
Best deep analysis on Intel CPUs. Memory latency, NUMA effects, vectorization efficiency, threading.
- Microarchitecture analysis — frontend/backend bound
- Memory access pattern analysis
- NUMA, UMA, threading hotspots
- Vectorization advisor
- Free via Intel oneAPI
- Excellent GUI with annotated source
Sub-microsecond frame profiler for games and real-time apps. The standard in the game dev industry.
- Nanosecond-precision instrumented zones
- Frame timeline view — perfect for game loop analysis
- Memory allocation tracking
- Lock / mutex contention visualization
- GPU zones (Vulkan, D3D12, OpenGL)
- Zero overhead when not connected
Instruction-accurate profiling. Catches every function call. Slow but deterministic — great for algorithmic analysis.
- Instruction-accurate — finds every call, no sampling error
- Call graph with exact counts
- Cache simulation (L1, LL cache misses)
- KCachegrind GUI for visual call tree
- Good for algorithmic complexity analysis
Google's open-source production profiler. Sampling with function-level instrumentation on demand.
- Live profiling of running processes
- Sampling baseline + targeted instrumentation
- Can instrument specific functions at runtime
- Good for production systems
Flame graph workflow with perf
# Record with call graphs (frame pointers or DWARF) sudo perf record -F 99 -g -- ./myapp # Generate flame graph (requires FlameGraph scripts) sudo perf script | stackcollapse-perf.pl | flamegraph.pl > flamegraph.svg # Or use the Hotspot GUI (recommended) # Install: apt install hotspot hotspot perf.data
Deep-dive guides
Heaptrack for C++ — tracking heap allocations, finding memory leaks, peak consumption, allocation hotspots, and GUI visualization.
Using Linux perf — perf stat, perf record/report, flame graphs, hardware counters, cache misses, branch mispredictions, and perf annotate.
C++ performance profiling tools — Tracy frame profiler, Linux perf, Valgrind Callgrind, gprof, and interpreting results to find real hotspots.
Valgrind Memcheck, Callgrind, Helgrind, and DRD — detecting memory errors, use-after-free, leaks, data races, and reading Valgrind reports.