xhprof的使用
来源:互联网 发布:西门子选型软件sizer 编辑:程序博客网 时间:2024/04/29 22:56
听说服务器上使用xhprof更好,于是参考了老王的博客,动手试了下。
wget http://pecl.php.net/get/xhprof-0.9.2.tgz
tar zxf xhprof-0.9.2.tgz
cd xhprof-0.9.2
cp -r xhprof_html xhprof_lib <directory_for_htdocs>
cd extension
phpize
./configure
make
make install
编辑php.ini:
[xhprof]
extension=xhprof.so
;
; directory used by default implementation of the iXHProfRuns
; interface (namely, the XHProfRuns_Default class) for storing
; XHProf runs.
;
xhprof.output_dir=<directory_for_storing_xhprof_runs>
使用XHProf:
如,在a.php中
// start profiling
xhprof_enable();
// run program
....
// stop profiler
$xhprof_data = xhprof_disable();
//
// Saving the XHProf run
// using the default implementation of iXHProfRuns.
//
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php"; //注意,这里和下一行的路径一定要正确,否则下面的new XHProfRuns_Default();就提示找不到class了
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php";
$xhprof_runs = new XHProfRuns_Default();
// Save the run under a namespace "xhprof_foo".
//
// **NOTE**:
// By default save_run() will automatically generate a unique
// run id for you. [You can override that behavior by passing
// a run id (optional arg) to the save_run() method instead.]
//
$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";
通过浏览器访问a.php,则在上面设定的xhprof.output_dir目录里生成名字类似49bafaa3a3f66.xhprof_foo的数据文件
然后可以通过web方式来查看
http://<xhprof-ui-address>/index.php?run=49bafaa3a3f66&source=xhprof_foo
<xhprof-ui-address>为xhprof_html所在的webserver的host,例,我的xhprof_html拷至了apache的htdocs下,webserver的documentroot为apache/htdocs,因此为http://a.com/xhprof_html/index.php?run=49bafaa3a3f66&source=xhprof_foo。source的值是死的,run就是xhprof.output_dir下要查看的文件名,不必多说了。
- xhprof的使用
- xhprof 的基本使用
- php xhprof 扩展的使用
- Xhprof的安装与使用
- xhprof性能工具的使用
- xhprof使用
- linux下XHProf的安装和使用
- 使用 XHProf 分析你的 PHP 程序
- 【程序性能分析】xhprof的使用例子
- 使用 XHProf 分析你的 PHP 程序
- window wamp下xhprof的安装使用
- xhprof扩展的安装和简单使用
- xhprof安装和使用
- XHProf安装使用笔记
- XHProf安装使用笔记
- XHProf安装使用笔记
- XHProf安装使用笔记
- xhprof安装&&使用
- 80X86常用汇编指令集(不断补充完善中)
- 须知
- WIN7任务栏资料管理器最近打开项目的管理及开始属性“存储并显示最近在开始菜单和任务栏中打开的项目”的解释
- hdu 4001 (2011ACM/ICPC大连网络赛)
- C++ Primer Plus学习:第九章 内存模型和名称空间(1)
- xhprof的使用
- Log4j使用总结
- Android背景透明的 Dialog
- 64位Windows Vista 和Windows 7系统下驱动签名指南
- Ice读书笔记--- TreadControl类的join与detach方法
- Redmine:工程管理软件不错啊
- 发掘 Windows 7 之 开始菜单搜索框
- 常用JS代码
- Linux中的head和tail命令