Cachegrind – Profiling Tool

I’ve recently worked in a code test project in my company A8C and it has a task to improve the performance of an existing code. The excellent part is that the test gives a suggestion to use cachegrind. I was really impressive how this tool can help profiling the code, visualize profiling results, and find out exactly places where performance issues happen.

  • First time, I used this tool and I could narrow down potential places to improve the code. The code execution time was reduced from not-possible-to-load to 20 seconds.
  • Second time, I profiled the code again and continued finding out a function still took most of execution time. I changed the approach of the code a bit, and the final result was impressive – just less 1 second.

If I had not known this tool, I would have not done this task efficiently.

The fancy and impressive part of the tool is visualization like this:


Reference links:


  • AFAIK, there are two tools kcachegrind and qcachegrind. I was successful in installing qcachegrind on my Mac.
  • I used this tool for PHP only with the profiling log from Xdebug. But from what I can understand, any language can use this tool as long as it has proper profiling log files.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s