Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do a read a xdebug profile in webgrind?

I have setup xdebug and webgrind and I have generated a profile so I can start improving the speed of my code execution. I have displayed the profile in webgrind but I haven't got a clue what any of it means. All the googling I have done doesn't really explain any of it either.

Could someone please explain the basics of reading a webgrind report:

Invocation Count

Total Self Cost

Total Inclusive Cost

What the different colours mean

What the coloured bar means

Calls

Total Call Cost

Count

like image 843
David Avatar asked Aug 17 '11 14:08

David


People also ask

What is Xdebug profiling?

Xdebug's Profiler is a powerful tool that gives you the ability to analyse your PHP code and determine bottlenecks or generally see which parts of your code are slow and could use a speed boost.

What is Xdebug trace?

Xdebug allows you to log all function calls, including parameters and return values to a file in different formats. Those so-called "function traces" can be a help for when you are new to an application or when you are trying to figure out what exactly is going on when your application is running.

How does Xdebug remote work?

When Xdebug is running, it will call back to your IDE (like PhpStorm or VS Code) from the server where it's running. Your IDE will sit and listen for that connection on a specific port (typically port 9000 or 9003).


1 Answers

The basic output lists all the different functions, methods, and included/required files.

  • Invocation Count: The number of times the function has been called

  • Total Self Cost: The total time it took to execute the raw php in this function (time taken to execute your other custom functions is excluded.)

  • Total Inclusive Cost: Total time, including any other functions called (PHP internal, or your functions)

  • What the different colours mean?

    • Blue are PHP internal functions
    • Green are your class methods
    • Orange are procedural functions
    • Grey is time taken to include, or require .php files.
  • What the coloured bar means? Graphical display of breakdown of time for each type as above.

  • For the last ones, I assume you've clicked the arrow to open a particular function?

    • Calls: The functions/methods called in executing this function

    • Total Call Cost: The total time executing this function, when called from the parent function

    • Count: Number of times the parent calls the child.

like image 124
ChrisA Avatar answered Sep 28 '22 14:09

ChrisA