介绍
官网的我直接拿过来了
XHProf 是一个轻量级的分层性能测量分析器。 在数据收集阶段,它跟踪调用次数与测量数据,展示程序动态调用的弧线图。 它在报告、后期处理阶段计算了独占的性能度量,例如运行经过的时间、CPU 计算时间和内存开销。 函数性能报告可以由调用者和被调用者终止。 在数据搜集阶段 XHProf 通过调用图的循环来检测递归函数,通过赋予唯一的深度名称来避免递归调用的循环。
XHProf 包含了一个基于 HTML 的简单用户界面(由 PHP 写成)。 基于浏览器的用户界面使得浏览、分享性能数据结果更加简单方便。 同时也支持查看调用图。
XHProf 的报告对理解代码执行结构常常很有帮助。 比如此分层报告可用于确定在哪个调用链里调用了某个函数。
XHProf 对两次运行进行比较(又名 “diff” 报告),或者多次运行数据的合计。 对比、合并报告,很像针对单次运行的“平式视图”性能报告,就像“分层式视图”的性能报告
更多额外文档可以在 » facebook xhprof上找到。
安装
安装xhprof
下载地址:https://pecl.php.net/package/xhprof
由于我这里下载xhprof
/var/www/html # pecl list
Installed packages, channel pecl.php.net:
=========================================
Package Version State
redis 4.2.0 stable
xhprof 0.9.4 beta
先进行卸载
/var/www/html # pecl uninstall xhprof
Unable to remove "extension=xhprof.so" from php.ini
uninstall ok: channel://pecl.php.net/xhprof-0.9.
/var/www/html # pecl list
Installed packages, channel pecl.php.net:
=========================================
Package Version State
redis 4.2.0 stable
选择对应的版本
我这里下载的是0.9.4
/var/www/html # wget https://pecl.php.net/get/xhprof-0.9.4.tgz
--2021-07-15 10:28:07-- https://pecl.php.net/get/xhprof-0.9.4.tgz
Resolving pecl.php.net... 104.236.228.160
Connecting to pecl.php.net|104.236.228.160|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 842077 (822K) [application/octet-stream]
Saving to: 'xhprof-0.9.4.tgz'
xhprof-0.9.4.tgz 100%[==============================================================================================>] 822.34K 246KB/s in 3.3s
2021-07-15 10:28:13 (246 KB/s) - 'xhprof-0.9.4.tgz' saved [842077/842077]
/var/www/html # rm -rf xhprof-0.9.4*
/var/www/html # pecl install https://pecl.php.net/get/xhprof-0.9.4.tgz
downloading xhprof-0.9.4.tgz ...
Starting to download xhprof-0.9.4.tgz (842,077 bytes)
..........................................