How do I read the UI of qcachegrind?

Wesley Smith picture Wesley Smith · Oct 13, 2015 · Viewed 7.1k times · Source

I am using qcachegrind to view a Profile log that is created by Xdebug. I can view the file fine, but I have no clue what Im looking at.

I have tried Google but I just keep getting installation tutorials, nothing about how to understand the display.

  1. What does the below qcachegrind display tell me about my application
  2. Is there anything more I can view from this file, or is this all of the available data?

(please open image in new tab for a better view)


enter image description here

Answer

Tom picture Tom · Dec 10, 2016

Tools like qcachegrind and kcachegrind visualise the output of the Xdebug PHP profiler. The output of the profiler is practically a log of all PHP function calls with corresponding start time, execution time and hierarchy.

A typical view is shown in the following figure:

Laravel App

On the left side is the 'Flat Profile'. It lists all individual function calls from most time consuming to least time consuming. The 'Incl.' column shows the time consumed by the function including callees. The 'Self' column shows the time spent by the function excluding callees. The 'Called' and 'Function' columns show respectively the number of times a function is called and the name (plus namespace) of the function.

On the right side, various views are available to visualise callers and callees. The callers and callees correspond to the function selected on the left side.

In my screenshot at the top, the 'Callee Map' is opened. Each rectangle is a function call within the selected function (a callee) and each rectangle within is a callee of the callee. The size corresponds to the relative 'Incl'. time.

At the bottom, the 'All Callees' view shows the callees of the selected function order by whatever property you prefer.

A more detailed view is shown below:

Callers and callees

This is a function of a Laravel database function sorted on 'Self' time. You clearly see how the different function calls relate and what function takes up the most time: PDOStatement::execute. This is no surprise as it is a function that connects to an external database, queries it and waits for the result.

Back to your original screenshot: it tells you that your application spent most of time in PHP's session_start function (99.8%).