加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP性能测试工具xhprof安装与使用

发布时间:2020-12-13 21:23:25 所属栏目:PHP教程 来源:网络整理
导读:原文链接:http://www.orlion.ga/711/ 一、安装 wget?https://pecl.php.net/get/xhprof-0.9.4.tgztar?zxf?xhprof-0.9.4.tgzcd?xhprof-0.9.4.tgz/extension/usr/local/php/bin/phpize./configure?--with-php-config=/usr/local/php/bin/php-configmakemake?in

原文链接:http://www.orlion.ga/711/

一、安装

wget?https://pecl.php.net/get/xhprof-0.9.4.tgz
tar?zxf?xhprof-0.9.4.tgz
cd?xhprof-0.9.4.tgz/extension
/usr/local/php/bin/phpize
./configure?--with-php-config=/usr/local/php/bin/php-config
make
make?install

????然后修改php.ini,加上:

extension=xhprof.so
xhprof.output_dir=/var/tmp/xhprof

????如果php-fpm启动的话就重启。

?

二、使用

????将xhprof解压包中的xhprof_html目录和xhprof_lib目录复制到服务器web目录或者是项目目录或者是其他任何php有权限能访问到的目录

? ? 然后在要测试的php代码前面加上xhprof_enable();然后在测试的php代码后加上

????????$xhprof_data?=?xhprof_disable();

????????require?"xhprof_lib/utils/xhprof_lib.php";
????????require?"xhprof_lib/utils/xhprof_runs.php";

????????$xhprof_runs?=?new?XHProfRuns_Default();

????????$run_id?=?$xhprof_runs->save_run($xhprof_data,?"xhprof_foo");

????????$url?=?"/xhprof_html/index.php?run=$run_id&source=xhprof_foo";
????????echo?'<a?href="'.$url.'">'.$url.'</a>';

????运行程序然后点击输出的链接就可以了。

????还要装一个图形化工具:

yum?install?graphviz
yum?install?graphviz-gd

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读