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:
- https://kcachegrind.github.io/html/Documentation.html
- https://stackoverflow.com/questions/33094913/how-do-i-read-the-ui-of-qcachegrind
- https://formulae.brew.sh/formula/qcachegrind
Note:
- AFAIK, there are two tools
kcachegrindandqcachegrind. I was successful in installingqcachegrindon 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.