facebook php程序监控性能软件xhprof安装配置
来源:互联网 发布:公交ic卡数据 编辑:程序博客网 时间:2024/06/04 00:21
xdebug部署线上服务,消耗太厉害,所以用xhprof 安装
安装前说明 我php装在/usr/local/php下,虚机建在/usr/local/www/uusnn.com.cn下
1.下载安装
<pre> 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 /usr/local/www/uusnn.com.cn
cd extension
/usr/local/php/bin/phpize
./configure
make
make install</pre>
2.php.ini配置
<pre>[xhprof]
extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/xhprof.so
;
; directory used by default implementation of the iXHProfRuns
; interface (namely, the XHProfRuns_Default class) for storing
; XHProf runs.
;
xhprof.output_dir=/var/log/xhprof/</pre>
3.测试代码,用自带的这个简单的php函数
如果想知道cpu和内存使用情况可以这样写就行了
<pre><span style="color: #ff0000;">xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
</span></pre>
<pre>
< ?php
// start profiling
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
// run program
function bar($x) {
if ($x > 0) {
bar($x - 1);
}
}
function foo() {
for ($idx = 0; $idx < 2; $idx++) {
bar($idx);
$x = strlen("abc");
}
}
foo();
// stop profiler
$xhprof_data = xhprof_disable();
//
// Saving the XHProf run
// using the default implementation of iXHProfRuns.
//
include_once "xhprof_lib/utils/xhprof_lib.php";
include_once "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_html\index.php?run=$run_id&source=xhprof_foo\n".
"---------------\n";
</pre>
4.写个文件看看他
现在执行上面的文件,可保存为xhprof.php
http://www.uusnn.com.cn/xhprof/xhprof.php
4d1b0c6fe2456.xhprof_foo 为生成的文件,是php的序列化数字
<pre>< ?php
$html = file_get_contents('/var/log/xhprof/4d1b0c6fe2456.xhprof_foo');
print_r( unserialize($html));</pre>
< 原创,转载请说明出处www.uusnn.com.cn>
<!--more-->
4.打印结果
Array
(
[foo==>bar] => Array
(
[ct] => 2
[wt] => 81
)
[foo==>strlen] => Array
(
[ct] => 2
[wt] => 1
)
[bar==>bar@1] => Array
(
[ct] => 1
[wt] => 1
)
[main()==>foo] => Array
(
[ct] => 1
[wt] => 201
)
[main()==>xhprof_disable] => Array
(
[ct] => 1
[wt] => 0
)
[main()] => Array
(
[ct] => 1
[wt] => 219
)
)
安装前说明 我php装在/usr/local/php下,虚机建在/usr/local/www/uusnn.com.cn下
1.下载安装
<pre> 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 /usr/local/www/uusnn.com.cn
cd extension
/usr/local/php/bin/phpize
./configure
make
make install</pre>
2.php.ini配置
<pre>[xhprof]
extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/xhprof.so
;
; directory used by default implementation of the iXHProfRuns
; interface (namely, the XHProfRuns_Default class) for storing
; XHProf runs.
;
xhprof.output_dir=/var/log/xhprof/</pre>
3.测试代码,用自带的这个简单的php函数
如果想知道cpu和内存使用情况可以这样写就行了
<pre><span style="color: #ff0000;">xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
</span></pre>
<pre>
< ?php
// start profiling
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
// run program
function bar($x) {
if ($x > 0) {
bar($x - 1);
}
}
function foo() {
for ($idx = 0; $idx < 2; $idx++) {
bar($idx);
$x = strlen("abc");
}
}
foo();
// stop profiler
$xhprof_data = xhprof_disable();
//
// Saving the XHProf run
// using the default implementation of iXHProfRuns.
//
include_once "xhprof_lib/utils/xhprof_lib.php";
include_once "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_html\index.php?run=$run_id&source=xhprof_foo\n".
"---------------\n";
</pre>
4.写个文件看看他
现在执行上面的文件,可保存为xhprof.php
http://www.uusnn.com.cn/xhprof/xhprof.php
4d1b0c6fe2456.xhprof_foo 为生成的文件,是php的序列化数字
<pre>< ?php
$html = file_get_contents('/var/log/xhprof/4d1b0c6fe2456.xhprof_foo');
print_r( unserialize($html));</pre>
< 原创,转载请说明出处www.uusnn.com.cn>
<!--more-->
4.打印结果
Array
(
[foo==>bar] => Array
(
[ct] => 2
[wt] => 81
)
[foo==>strlen] => Array
(
[ct] => 2
[wt] => 1
)
[bar==>bar@1] => Array
(
[ct] => 1
[wt] => 1
)
[main()==>foo] => Array
(
[ct] => 1
[wt] => 201
)
[main()==>xhprof_disable] => Array
(
[ct] => 1
[wt] => 0
)
[main()] => Array
(
[ct] => 1
[wt] => 219
)
)
- facebook php程序监控性能软件xhprof安装配置
- PHP性能监控软件xHprof
- PHP性能监控软件XHProf的安装和使用(原创)
- xhprof安装以及php程序性能测试
- PHP性能监控测试----Xhprof
- facebook工具xhprof的安装与使用-分析php执行性能
- facebook工具xhprof的安装与使用-分析php执行性能
- PHP - xhprof+Graphviz 安装配置
- PHP - xhprof+Graphviz 安装配置
- 实用php性能分析工具XHProf(facebook)
- windows配置xhprof,PHP性能分析工具
- PHP性能优化工具–xhprof安装
- xhprof PHP的性能监控神器 mac 环境
- php性能分析工具XHProf安装配置使用教程(linux精华版)
- Php性能分析-xhprof
- Xhprof----facebook开源的,轻量级的PHP性能分析工具
- PhalApi-Xhprof -- Facebook开源的轻量级PHP性能分析工具
- 【PHP性能优化学习】之xhprof安装&&使用
- Another app is currently holding the yum lock 解决办法!
- oracle 按每天,每周,每月,每季度,每年查询统计数据
- php 5.3.4安装配置(原创)
- iOS 改变 已有 工程的 名字
- Java 连接oracle11g2
- facebook php程序监控性能软件xhprof安装配置
- Android APK+Dex文件反编译及回编译工具
- DATEDIFF() 定义和用法
- Android APK反编译得到Java源代码和资源文件
- Spring security 认证-列子(1)
- mysql 5.5.8 源码安装
- hdu 2401
- sharepoint 2010 会议室预订系统-资源预订系统
- 程序员技术练级攻略