lampp安装xhprof,亲测成功

来源:互联网 发布:销售管理数据流程图 编辑:程序博客网 时间:2024/06/05 04:40
  1. 先到LAMPP官网下载LAMPP
  2. 到PHP官网下载xhprof
  3. 解压xhprof
  4. 在命令行中进入到    xhprof-0.9.4/extension目录
  5. 继续输入:sudo   /opt/lampp/bin/phpize
  6.  ./configure --with-php-config=/opt/lampp/bin/php-config --prefix=/opt/lampp/
  7.  make
  8. make test
  9. make install
  10. 之后就会看到安装完成的提示。去 /opt/lampp/lib/php/extensions/no-debug-on-zts-20060613/ 下查看,会看到已经有 xhprof.so 了。

  11. 在 /opt/lampp/etc/php.ini 中添加
    extension="xhprof.so" ,(注:如果是64位系统需要将xhprof.so文件拷贝到相关的lib64的目录下)
    xhprof.output_dir
    ="/tmp/xhprof"(如果TMP目录下没有XHPROF目录要创建目录,否则会报错)
    重启lampp。
  12. 重启服务器后,就可以看到phpinfo中xhprof的信息了。

   开始测试

  1. 将代码加入到要测试的php当中
  2. <?phpxhprof_enable ( XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY );//下面是要测试的代码function demo(){sleep(3);echo "xixi";echo "<br/>";}demo();//上面是要测试的代码$xhprofData = xhprof_disable ();//下面的include_once中的目录,需要自定义include_once "/opt/lampp/htdocs/xhprof/xhprof_lib/utils/xhprof_lib.php";include_once "/opt/lampp/htdocs/xhprof/xhprof_lib/utils/xhprof_runs.php";$xhprofRuns = new XHProfRuns_Default ();$run_id = $xhprofRuns->save_run ( $xhprofData, "xhprof" );//在浏览器直接打开这个链接就可以查看性能分析结果。echo "http://localhost/xhprof/xhprof_html/index.php?run={$run_id}&source=xhprof\n";?>
  3. <pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: 'Courier new';"><span style="font-family:'Courier new';">下面是一些参数说明Inclusive Time                 包括子函数所有执行时间。Exclusive Time</span>/<span style="font-family:'Courier new';">Self Time  函数执行本身花费的时间,不包括子树执行时间。Wall Time                        花去了的时间或挂钟时间。CPU Time                        用户耗的时间</span>+<span style="font-family:'Courier new';">内核耗的时间Inclusive CPU                  包括子函数一起所占用的CPUExclusive CPU                  函数自身所占用的CPU</span>



0 0