Analyzing Xdebug Profiling Data
When integration with Xdebug profiler is enabled, PhpStorm provides visual representation of profiler snapshots. PhpStorm opens a separate editor tab with four views where the data are presented based on different criteria.
To have the profiling data collected and analyze it, perform these general steps:
- Initiating an Xdebug debugging session
- Retrieving the data accumulated by the profiler
- Examining the profiling data
Initiating an Xdebug debugging session
To start an Xdebug session, do one of the following:
- To start debugging an entire application, create debug configuration of the type PHP Web Application, and launch debugging by clicking the Debug toolbar button .
See Debugging with a PHP Web Application Debug Configuration for details.
- To debug a specific PHP HTTP request, define a debug configuration of the type PHP HTTP Request, and launch debugging by clicking the Debug toolbar button .
See Debugging a PHP HTTP Request for details.
- To initiate a zero-configuration debugging session:
- Toggle the Start Listen PHP Debug Connections button so it changes to . After that PhpStorm starts listening to the port of the debugging engine used in the current project. Ports for debuggers are set at the PhpStorm level in the Debug dialog box (File | Settings | PHP | Debug for Windows and Linux or PhpStorm | Preferences | PHP | Debug for macOS).
- Open the starting page of your application in the browser, choose the Start debugger bookmark to activate the debugging engine from the browser, re-load the current page (the starting page of the application), and then return to PhpStorm.
Retrieving the data accumulated by the profiler
- On the main menu, choose .
- In the Select Xdebug profiler snapshot dialog box, that opens, choose the folder and the file where the profiling data is stored.
PhpStorm presents the collected profiling data in a separate editor tab with the name of the selected profiler output file.
Examining the profiling data
When you request on the accumulated profiling data, PhpStorm opens its visualized presentation in a separate editor tab. The tab is named after the selected profiler output file and consists of several views. Switch between the views to analyze the profiling data based on various criteria of analysis.
- In the Execution Statistics view, examine the summary information about execution metrics of every called function.
- In the Call Tree view, explore the execution paths of all called functions.
- To explore the execution paths of a specific function, select the function in question in the Call Tree view and view its callees in the Callees view.
- To explore all the paths that can result in calling a specific function, select the function in question in the Call Tree view and examine its possible callers in the Callers view.