4 ms·
Turn on all compiler warnings (-Weverything for Clang and RTFM for GCC (no, -Wall doesn't turn all the warnings on)). Scanbuild (LLVM based, Linux and macOS)
by Elv13 10y ago
Turn on all compiler warnings (-Weverything for Clang and RTFM for GCC (no, -Wall doesn't turn all the warnings on)).
Scanbuild (LLVM based, Linux and macOS)
Perf (recent Linux) or DTrace (macOS, SmartOS, Solaris and FreeBSD)
Valgrind (Linux, macOS) with the KCacheGrind/QCacheGrind (CPU usage), Valkyrie (leaks and undefined behavior) and Massif-visualizer (memory usage) GUIs
The compiler sanitizers (GCC, LLVM, Linux and macOS)
strace (Linux)
HeapTrack (Linux, a true hidden gem, best memory profiler ever)
Binutils (Linux, macOS)
And really, get to know your debugger. Both GDB and the Visual studio debugger are extremely powerful. If you think a debugger does beakpoints and nothing else, you really, really need to get to know your debugger better. LLDB is getting there too, it will catch up soon (surprising given how long it took the other 2 to mature).
For people from a Python background, know that both GDB and LLDB are available as a Python shell with full access to the C program internal. You can add triggers to execute Python callbacks, conditional breakpoints and even gather stat and have them display in MathPlotLib or iPython Notebook.
- jononor 10y agoAny good references to gathering stats using debugger and visualizing with Python?
- Elv13 10y agoGood luck finding anything. It is in many performance ninjas arsenal, but very little documented. Here is an untested mix of some other scripts that might less or more almost work. At least it can get you started: https://gist.github.com/Elv13/48b43ead347faba1b59378267d2364e7 https://gist.github.com/Elv13/48b43ead347faba1b59378267d2364...