A long time ago, in grad school, my advisor taught me to use gprof, a tool that produced a report showing where all the CPU time was spent in one’s program. Gprof required recompiling the program with special instrumentation, and its instrumentation granularity wasn’t great, but it provided invaluable data about performance bottlenecks. Ever since then, I’ve been a user and advocate of software performance profiling tools.
The basics of performance profiling have remained largely the same over the years, but the tools have grown more sophisticated.
A couple of years into my career, I started using Quantify, an application from Pure Software. It worked by rewriting the compiled code at link time to add timing support. This technique offered two nice advantages over gprof: because it ran after the compiler and didn’t require source code, Quantify could instrument third-party, binary-only libraries; and Quantify’s time measurement was much more precise than gprof’s.
In 2002, I found OProfile for Linux. It was even more convenient to use than Quantify. Rather than instrumenting the program’s code, OProfile worked at the system level, taking advantage of performance counters built into modern CPUs to profile any running process–and even the kernel–with low overhead.
A couple of years later, I used Shark, one of the developer tools included with Xcode on Mac OS X. Shark did basically the same thing as OProfile–collect a sample, and then turn it into a human-readable report–but with an easy-to-use GUI.
This afternoon I wanted to study the CPU usage of memcached, so I tried out the profiling tools in the latest version of Xcode. Shark is still there, but there’s also a new tool called Instruments that trumps every previous profiler I’ve used by displaying and continuously updating the profile report in real time:

Thinking about the evolution of profiling tools over the years, from gprof to Instruments, I’m struck by how much I appreciate the advances in usability. Software performance optimization is a complex and somewhat specialized skill set, and anyone who understands the output of a profiler is probably quite capable of figuring out the compiler flags for gprof. Back in school, my younger self probably would have scoffed at the idea of an automated, real-time, GUI-based profiling tool. Today, though, having spent a career dealing with ever-increasing complexity, I’m very happy to find that someone has done the work to encapsulate profiling in an easy-to-use GUI so I can spend less time figuring out the tools and more time doing useful work.






