2.8.23. PHP profiling

Profiling — collection of detailed information about the time of the script functions and the consumption of RAM in the process of processing a request to the site. Using this information, the site developer can identify the slowest parts of the code in order to optimize them in the future and reduce the time of the scripts.

What profiling can show:

  • What functions and how many times were executed during the script.
  • How long each function took to run.
  • How much RAM was used by the function and peak consumption values.
  1. Turnon profiler.
  2. Add to list your IP or developer address.
  3. Follow the steps on the site for which you want to collect information.
  4. Explore reports or provide them to the site developer to find ways to optimize.
For profiling, use the extension XHProf.

Important points:

  • Profiler can be enabled for sites with PHP versions 7.0-8.3.
  • The option is automatically disabled while the profiler is running. open_basedir.
  • Profiler reports are stored in disk space hosting account and take up space and inodes.

Working with the profiler is performed in the section "PHP profiling".

Notes:

  • When included in php.ini the extension is connected and the view directive is added auto_prepend_file = "/home/{$login}/.system/profiler/profiler_{$host_id}.php" to run the profiler.
  • The directive is added separately and does not affect added previously auto_prepend_file.
  • Switching on occurs not instantly — there is a slight delay of a few minutes required for changes in PHP settings to be applied.

Select the desired time in the block "PHP profiling" and press "Enable Profiler":

Add to the list the IPs from which requests will start the profiler:

Attention!

Reports are displayed in the control panel only under the following conditions:
  • For hosting accounts in Ukraine — the size of the report file should be no more than 100 MB.
  • For hosting accounts in other countries — the size of the report file should be no more than 10 MB.

Notes:

  • The list of reports is displayed from newest to oldest.
  • Report files are stored in the directory .system/profiler in the root directory of the hosting account.
  • Reports are deleted only manually. Thus, they remain available for analysis after the profiler is disabled.

All profiler results are displayed in the block "Profiler reports":

The block displays the current volume occupied by existing reports on the disk. Here you can also delete all reports with the button "clear".

List columns:

  • "Date" — date and time the request was processed.
  • "URL" — Request URL.
  • "CPU" — CPU time while processing a request.
  • "Lead time" — script running time when processing a request.
  • "Peak Memory Consumption" — maximum memory consumption during request processing.

Button "Detailed report" opens detailed information about how the script works when processing a request:

In a detailed report:

  • "Date and time the script was run".
  • "IP" — The IP from which the request was made.
  • "Exact URL" — The URL to which the request was made.
  • "Number of function calls" — the number of functions executed by the script when processing the request.
  • "Distribution of functions by execution time" — a graph with the proportions of the execution time of various functions in relation to the total time spent.

Columns of the general list of called functions:

  • "Function" — the name of the function.
  • "Number of calls" — how many times the function was executed.
  • "Measures including child functions":
    • "Lead time" — how long the function took to complete.
    • "CPU" — how long the processor was busy executing the function.
    • "Memory consumption" — how much memory was used during the execution of the function.
    • "Peak Memory Consumption" — peak value of memory usage when executing the function.
  • "Metrics excluding child functions" — similar to the indicators above, only without taking into account child functions.
A dash means that the profiler was unable to reliably calculate the value of the indicator.

Clicking on a function name opens a detailed report on that function:

Report columns by function:

  • "Function" — the name of the function.
  • "Number of calls" — how many times the function was executed.
  • "Execution time, ms" — How long did the function take to complete?
  • "CPU, ms" — how long the processor was busy executing the function.
  • "Memory consumption, bytes" — how much memory was used during the execution of the function.
  • "Peak memory consumption, bytes" — peak value of memory usage when executing the function.

The functions in the list are divided into three groups:

  • "Current function" — the function, information about which is currently open.
  • "Parent functions" — functions from which the current function was called.
  • "Child functions" — functions that were called from the current function.

By clicking on the names of parent/child functions, you can move through the hierarchy of all called functions and view information on each of them.

Click "Disable profiler" in the block "PHP profiling" or wait for the automatic shutdown time:

Content