Home  >  Article  >  Backend Development  >  Analyze PHP program running performance (consumption)

Analyze PHP program running performance (consumption)

little bottle
little bottleforward
2019-04-17 13:43:362906browse

After using xdebug, php can configure xdebug related configurations and generate running logs. This article is about the analysis of the running performance of PHP programs. Interested friends can learn more.

Configure in php.ini:

  1. xdebug.profiler_enable = 1
  2. xdebug.profiler_enable_trigger = 1
  3. xdebug.profiler_output_name = cachegrind. out.%t.%p
  4. xdebug.profiler_output_dir ="d:/xdebug/"

In this way, the log file will be generated to the d:/xdebug/ directory:

Analyze PHP program running performance (consumption)

Every time php is executed, a corresponding log file will be generated. There used to be a tool called WinCacheGrind that could be used to analyze this kind of log, but WinCacheGrind was no longer maintained in 2015. The latest version is 1.0.0.14, which only supports xdebug2. When you open the log file, an error will be reported: "Cannot find target ".

In fact, the powerful phpstorm comes with the function of performance log analysis. Open Tools->Analyze Xdebug Profiler Snapshot..

Analyze PHP program running performance (consumption)

and then select D: After opening the log file under \xdebug, you can see the tree relationship of function calls and the execution time of each function

Analyze PHP program running performance (consumption)

In this way, you can find out which one Function execution is time-consuming.

[Recommended course: PHP video tutorial]

The above is the detailed content of Analyze PHP program running performance (consumption). For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete