例子:
1.配置代码:
//测试开始配置代码
xhprof_enable(XHPROF_FLAGS_CPU+ XHPROF_FLAGS_MEMORY);
//测试的代码块开始
$this->view->datas= $this->objCrudpcapp->search($this->postData);
$this->view->postData['PGC']=1;
//测试的代码块结束
//结束代码块开始
$xhprof_data =xhprof_disable();
include_once(Z_ENV_HTDOCS."/xhprof_lib/utils/xhprof_lib.php");
include_once(Z_ENV_HTDOCS."/xhprof_lib/utils/xhprof_runs.php");
//include_once(Z_WEB_ROOT."/xhprof_lib/utils/xhprof_lib.php");
//include_once(Z_WEB_ROOT."/xhprof_lib/utils/xhprof_runs.php");
$objXhprofRun = newXHProfRuns_Default();
$run_id =$objXhprofRun->save_run($xhprof_data, "xhprof_pc");
echo "<ahref='/xhprof_html/index.php?run=".$run_id."&source=xhprof_pc'target='_blank'>view</a>";
//结束代码块结尾
2.打开生成log的链接
xhprof
http://localhost/xhprof_html/index.php?run=53202d4ae920d&source=xhprof
3.报告查看参照以下链接:
http://www.ec-os.net/misc/xhprof.html
(1). 查看单个报告。
# 我们想要查看 4b4c239a86593.xhprof 这个报告的详细信息,查看链接如下:
http://host/xhprof_html/index.php?run=4b4c239a86593&source=xhprof
(2). 比较两个报告。
# 我们想比较 4b4c239a86593.xhprof 和4b4c2645794f0.xhprof 两个报告,查看链接如下:
http://host/xhprof_html/index.php?run1=4b4c239a86593&run2=4b4c2645794f0&source=xhprof
我们可以看到精确到函数级的分析数据,包括调用次数、CPU、内存等,还可以不断的向下跟踪。