博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
php性能分析工具xhprof
阅读量:6976 次
发布时间:2019-06-27

本文共 1283 字,大约阅读时间需要 4 分钟。

安装方法:

wget http://pecl.php.net/get/xhprof-0.9.x.tgz

cp xhprof-0.9.x.tgz /home/www/xhprof.tgz

 

tar zxvf /home/www/xhprof.tgz

cd xhprof/extension

phpize

./configure --enable-xhprof --with-php-config=/usr/bin/php-config

make && make install

vim /etc/php.ini

[xhprof]extension=xhprof.so;下面的这个地址是用来保存测量记录的目录,在页面输出测量得到的数据的时候,它会自动到这儿来找输出的文件。xhprof.output_dir=/tmp

 service php-fpm restart

ok!

使用方法:

0) { bar($x - 1); }}// 在代码开头加上xhprof_enable();// xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);这个还可以分析cpu和内存使用情况// 你的程序foo();// 在代码结尾加上$xhprof_data = xhprof_disable();// xhprof的数据print_r($xhprof_data);//这里是xhprof的地址,echo出来直接复制地址访问可以查看报告$XHPROF_ROOT = realpath(dirname(__FILE__) .'/..');include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php";include_once $XHPROF_ROOT . "/xhprof_lib/utils/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://
/index.php?run=$run_id&source=xhprof_foo\n". "---------------\n";

 

转载地址:http://zhesl.baihongyu.com/

你可能感兴趣的文章
信号练习
查看>>
UML类图几种关系的总结
查看>>
JavaScript学习笔记——流程控制
查看>>
iOS:第三方数据库文件FMDB的使用
查看>>
M面经prepare: Shuffle a deck
查看>>
Storm集群部署
查看>>
Socat
查看>>
linux系统编程:进程间通信-mmap
查看>>
CCF系列之ISBN号码(201312-2)
查看>>
QQ邮箱如何设置SMTP代理收发邮件
查看>>
二叉树的应用详解 - 数据结构
查看>>
JDBC学习笔记(1)——JDBC概述
查看>>
cannot create windows service for mysql
查看>>
iOS 中实现功能引导页面
查看>>
3年路漫漫,告别老东家
查看>>
呼吁身份证号码识别生日的问题
查看>>
函数依赖的公理化系统
查看>>
open Command window here
查看>>
Spring boot 启动过程解析 logback
查看>>
@ActiveMQ简单介绍以及安装
查看>>