xhprof性能分析工具

安装xhprof

clone https://github.com/longxinH/xhprof
cd xhprof/extension/
phpize
./configure 
make
make install
php.ini文件中添加 extension=xhprof.so

xhprof分析ci框架

xhprof参数含义

Function Name:方法名称。

Calls:方法被调用的次数。

Calls%:方法调用次数在同级方法总数调用次数中所占的百分比。

Incl.Wall Time(microsec):方法执行花费的时间,包括子方法的执行时间。(单位:微秒)

IWall%:方法执行花费的时间百分比。

Excl. Wall Time(microsec):方法本身执行花费的时间,不包括子方法的执行时间。(单位:微秒)

EWall%:方法本身执行花费的时间百分比。
cd xhprof
复制 xhprof_html xhprof_lib 两个文件夹到CI框架index.php同目录
复制 xhprof/xhprof_lib/utils/xhprof_lib.php
     xhprof/xhprof_lib/utils/xhprof_runs.php
    两个文件到CI框架index.php同目录
框架开始加入代码:
xhprof_enable();
//默认情况下只有调用次数和占用时间是记录了的。您也可以选择同时记录CPU时间和/或单纯记录内存使用量。将下面这一行:
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
结束加入代码:
$xhprof_data = xhprof_disable();

// display raw xhprof data for the profiler run
        print_r($xhprof_data);
        include_once "xhprof_lib.php";
        include_once "xhprof_runs.php";

// save raw data for this profiler run using default
// implementation of iXHProfRuns.
        $xhprof_runs = new XHProfRuns_Default();

// save the run under a namespace "xhprof_foo"
        $run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_foo");

        echo "---------------\n".
            "Assuming you have set up the http based UI for \n".
            "XHProf at some address, you can view run at \n".
            "http://<xhprof-ui-address>/index.php?run=$run_id&source=xhprof_foo\n".
            "---------------\n";

访问网站www.test.com, 运行框架;
访问www.test.com/xhprof_html/index.php?run=$run_id&source=xhprof_foo得到分析结果
这里写图片描述

这里写图片描述

linux安装绘图工具

yum install libpng
yum install graphviz

这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值