Visualize with KCachegrind (QCachegrind)
Ruby-prof can generate profiles in so-called callgrind format. This is the format used by the Valgrind profiler used in the C and C++ world. With the CallTreePrinter, you can obtain the callgrind-formatted profile and reuse some of the best visualization tools developed by C/C++ programmers.
KCachegrind[11] is, in my opinion, the best such tool. It comes as a part of all major Linux distributions. Its version for Mac OS and Windows is called QCachegrind. On Mac you can install it via MacPorts or Homebrew. On Windows you can use precompiled packages.[12]
If you want to follow along, install it now, if necessary. And then let’s take our example application and generate the callgrind output. Add this ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access