Profiling Awesomeness

I wanted to take a few minutes to write a short message about code profiling. If you’re not familiar with code profiling, it’s essentially a way to allow you to look at a running application, and see what parts are being called, how often, and how much time you are spending in each function. This is a great way to get a handle on why something might not be running as quickly as possible. There are a couple of excellent tools for code profiling under Linux and in this post I’d like to mention two specific tools that go hand-in-hand, Valgrind and KCacheGrind.

Valgrind is a suit of tools which allows you to profile memory usage, cache usage, threads, and function calls. Running a program through valgrind slows the execution, but provides a great amount of information about your program. Unfortunately, the valgrind output is at times slightly obtuse. For this, KCacheGrind comes in handy. Even if you are developing under Gnome, KCacheGrind is perhaps one of the most useful linux development tools that I’ve used in recent memory. The CallGraph view, in particular, offers an interactive flow-chart-like graph of system and function calls, and their cost, for your application. An excellent way to get a handle on paths of execution that might slow down your program.


About this entry