Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to understand qcachegrind results?

I trying to profile my php app but cant understand indicators in qcachegrind. followed screenshot: enter image description here

its function calls of course. but what means columns incl. and self ? how should i recognize here that some method is need to refactor ?

like image 810
webcitron Avatar asked Mar 11 '23 19:03

webcitron


1 Answers

"self" is time of executing the function WITHOUT any includes (and other function calls) inside it and "include" is the whole time of function execute (with including files, function etc). Take an example:

function a()
{
    b();
    c();
}

function b() { // some code }
function c()
{  
   d()
}
function d() { // some code }

Function a self time will be approximately zero, but since it calls b and c, its include time will be highest and contains time for a, b and c. Similarly b self and include time will be same as it is not calling any function. Whereas c self will be approximately 0 and include time being approximately equal to d include time.

Looking at your qcachegrind, your code is spending a lot of time in the PDO calls. Something related with the SQL query. You also want to capture your SQL queries and profile them to see how they are doing.

Also interesting in the output is number of times a function is called. A function may be efficient in terms of performance, but if it is called too many times, it will add up. Check if the code if making too many SQL queries.

like image 186
Jay Rajput Avatar answered Mar 28 '23 21:03

Jay Rajput