php程式效能分析工具

2021-08-27 16:49:28 字數 914 閱讀 2624

平常開發一些效率要求比較高的功能模組時,常常需要分析程式的執行瓶頸在哪。用下面這個工具可以很方便的檢視php的指令碼執行過程。下面是配置步驟:

1. php安裝xdebug,網上很多教程,下面貼上php.ini中的配置項

[xdebug]

zend_extension=/usr/local/php54/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so

xdebug.profiler_output_dir="/mnt/hgfs/web/log/xdebug"

xdebug.profiler_output_name = "cachegrind.out.%t-%s"

xdebug.remote_autostart = on

xdebug.remote_enable = on

xdebug.profiler_enable_trigger=1

xdebug.remote_host="127.0.0.1"

xdebug.remote_port=9000

xdebug.remote_handler="dbgp"

xdebug.remote_mode=req

這樣配置後,平常執行php程式並不會生成效能除錯檔案,只有在url的字尾加上url引數 xdebug_profile=1 才會生成除錯檔案。除錯檔案在 xdebug.profiler_output_dir 這個引數配置的路徑中。

2. 安裝解析除錯檔案的工具 qcachegrind

開啟 qcachegrind,選擇前面生成的除錯檔案開啟即可檢視。

其實有好幾個這種型別的工具,這個是我用過覺得比較直接明了的。

golang程式效能分析

vegeta是乙個用go語言編寫的多功能的http負載測試工具,提供命令列工具和開發包。安裝見vegeta 說明。usage vegeta global flags command flags global flags cpus int 使用cup的數量 預設4 個 profile string e...

python程式效能分析

目錄 python m cprofile o output file s sort order m module myscript.py o將結果輸出到檔案而不是stdout s排序狀態,選擇那些引數排序,常用 tottime m作為乙個模組而不是指令碼,python3.7的cprofile中有,p...

Go程式效能分析pprof

參考 go語言的pprof是google c profiler的移植,所以用法也差不多。這裡簡要記錄步驟如下 1.import runtime pprof 引用pprof package os func main 2.執行 執行程式,生成profile檔案 3.分析 在命令列上執行 go tool ...