当前位置:网站首页>Performance tuning can't just depend on tapping the brain

Performance tuning can't just depend on tapping the brain

2022-06-13 07:08:00 guangsu.

qcachegrind

background

Quantifiable is the precondition of problem solving . Performance optimization cannot be limited to theoretical analysis , Quantitative indicators should be obtained with the help of performance analysis tools . So as to measure the optimization scheme more accurately .
Every mature language has its own performance monitoring tools . for example :

  • golang : pprof
  • php : xdebug , xhprof

These performance monitoring tools are time-consuming for the program by means of hook embedding , Memory usage , Call sequence and other key data to record . To generate a response monitoring report .
When these files are generated, they are recorded according to the unified reporting protocol , This makes it easy to use sophisticated analysis tools ( Or self-developed tools ) To parse the analysis report . At the same time, it is also convenient for
Develop common performance analysis tools to parse analysis reports generated in different languages .

The more popular single machine performance monitoring tools on the market are :

  • qcachegrind -> platform:Win / MacOS
  • kcachegrind -> platform:Linux
  • webgrind -> platform: Linux / Win / MacOS This is great

kcachegrind And qcachegrind It's essentially the same thing , It's just that they use different graphics engines .kcachegrind be based on KDE. and qcachegrind be based on Qt.

xdebug Generate performance analysis file ,qcachegrind Format the file , Provide good readability .

brew install graphviz
brew install qcachegrind

MacOS: qcachegrind install

  1. brew install graphviz Execute this command to install graphviz, be used for Call Graph function
  2. brew install qcachegrind install qcachegrind. ( If call graph The function cannot be used . please sudo ln -s /usr/local/bin/dot /usr/bin/dot)

function qcachegrind

#> nohup qcachegrind &    

dashboard Interpretation of indicators

  • invocation count
  • total inclusive cost => incl shows the time consumed by the function including callees
  • total self count shows the time consumed by the function not including callees cost

Word interpretation

  • caller caller
  • callees Callees
  • invocation call
  • invoke call , quoted

xdebug Configure the instance

[xdebug]

zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
xdebug.remote_enable=on
xdebug.idekey='PHPSTORM'
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9001

;  Performance analysis section 
xdebug.profiler_enable=Off
;  Enable the performance analysis trigger mode   Instead of triggering performance analysis for every request   And  xdebug.profiler_enable=0  When used in conjunction with :w
xdebug.profiler_enable_trigger=On
; url Contained in the XDEBUG_PROFILE Performance analysis will be triggered only when the parameters are aligned  eg. http://local.web.vhall.com/index.php?XDEBUG_PROFILE=aaa
xdebug.profiler_enable_trigger_value='aaa'
xdebug.profiler_output_dir="/Users/sujianhui/PhpstormProjects/profiler_output"
xdebug.profiler_output_name=callgrind.out.%u

Reference material

qcachegrind Installation guide https://blog.csdn.net/weixin_33881753/article/details/88923382
QCacheGrind Introduction to the use of tools https://blog.csdn.net/raoxiaoya/article/details/111994696
xdebug Quick reference table https://blog.csdn.net/qq624202120/article/details/64124087
phpstorm in xdebug Configuration of https://www.cnblogs.com/yjken/p/8435018.html
Interpretation of instrument cluster parameters https://stackoverflow.com/questions/33094913/how-do-i-read-the-ui-of-qcachegrind

原网站

版权声明
本文为[guangsu.]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202270550304504.html