windows 64位PHP5.5配置xhprof
2016-03-30 17:00
507 查看
windows 64位PHP5.5配置xhprof。
1.首先下载xhprof拓展,下载地址:http://windows.php.net/downloads/pecl/releases/xhprof/0.10.6/ ,选择对应的版本下,我本地是win64,PHP5.5 这里选择的是php_xhprof-0.10.6-5.5-ts-vc11-x64.zip,解压把php_xhprof.dll放到php\ext下,修改php.ini文件,在最低部加入下面代码:
[xhprof]
extension=php_xhprof.dll
; directory used by default implementation of the iXHProfRuns
; interface (namely, the XHProfRuns_Default class) for storing
; XHProf runs.
xhprof.output_dir="D:/wamp/www/xhprof_log"其中xhprof.output_dir的路径可以随便选择,但是要提前创建出该文件夹,注意不要有空格或中文,D:\wamp\www\xhprof_log为文件夹,运行xhprof时生成文件在该文件夹下。
重启apache,phpinfo()查看是否加载xhprof
2.下载xhprof日志记录的项目代码,地址:http://pecl.php.net/get/xhprof-0.9.4.tgz,解压把项目放到www目录下,项目包含示例代码,我这里把解压项目放到www目录下,并在www下创建sample.php,编辑代码:
<?php
// 运行的函数
function bar($x) {
$x++;
}
// 运行的函数
function foo() {
for ($idx = 0; $idx < 5; $idx++) {
bar($idx); // 这里意思为运行的函数再调用子函数,xhprof也会统计子函数的运行情况
}
}
// 开启记录
xhprof_enable(XHPROF_FLAGS_NO_BUILTINS | XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY);
// 运行用户的操作函数
foo();
// 结束统计记录并返回统计结果
$xhprof_data = xhprof_disable();
/* 引入xhprof统计结果的项目,把统计结果存入日志文件中
* 该项目还有统计结果的展示页,访问地址为:http://localhost/xhprof/xhprof_html/index.php
*/
$XHPROF_ROOT = realpath(dirname(__FILE__) .DIRECTORY_SEPARATOR.'xhprof');
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php";
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php";
// 统计结果存入日志文件--此时会创建一个日志文件,每次都会创建一个新的日志文件
$xhprof_runs = new XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_foo");
// run_id为日志文件的文件名
echo $run_id;
/* 结束保存记录日志 */
1.首先下载xhprof拓展,下载地址:http://windows.php.net/downloads/pecl/releases/xhprof/0.10.6/ ,选择对应的版本下,我本地是win64,PHP5.5 这里选择的是php_xhprof-0.10.6-5.5-ts-vc11-x64.zip,解压把php_xhprof.dll放到php\ext下,修改php.ini文件,在最低部加入下面代码:
[xhprof]
extension=php_xhprof.dll
; directory used by default implementation of the iXHProfRuns
; interface (namely, the XHProfRuns_Default class) for storing
; XHProf runs.
xhprof.output_dir="D:/wamp/www/xhprof_log"其中xhprof.output_dir的路径可以随便选择,但是要提前创建出该文件夹,注意不要有空格或中文,D:\wamp\www\xhprof_log为文件夹,运行xhprof时生成文件在该文件夹下。
重启apache,phpinfo()查看是否加载xhprof
2.下载xhprof日志记录的项目代码,地址:http://pecl.php.net/get/xhprof-0.9.4.tgz,解压把项目放到www目录下,项目包含示例代码,我这里把解压项目放到www目录下,并在www下创建sample.php,编辑代码:
<?php
// 运行的函数
function bar($x) {
$x++;
}
// 运行的函数
function foo() {
for ($idx = 0; $idx < 5; $idx++) {
bar($idx); // 这里意思为运行的函数再调用子函数,xhprof也会统计子函数的运行情况
}
}
// 开启记录
xhprof_enable(XHPROF_FLAGS_NO_BUILTINS | XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY);
// 运行用户的操作函数
foo();
// 结束统计记录并返回统计结果
$xhprof_data = xhprof_disable();
/* 引入xhprof统计结果的项目,把统计结果存入日志文件中
* 该项目还有统计结果的展示页,访问地址为:http://localhost/xhprof/xhprof_html/index.php
*/
$XHPROF_ROOT = realpath(dirname(__FILE__) .DIRECTORY_SEPARATOR.'xhprof');
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php";
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php";
// 统计结果存入日志文件--此时会创建一个日志文件,每次都会创建一个新的日志文件
$xhprof_runs = new XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_foo");
// run_id为日志文件的文件名
echo $run_id;
/* 结束保存记录日志 */
相关文章推荐
- PHP const 与 define的区别
- FTP客户端
- ThinkPHP的RBAC
- php +- month的坑
- 电脑无法登陆ftp
- PHP.INI安全配置
- 大话PHP设计模式
- PHP魔术方法使用
- php 数组去重
- PHP中file_exists()函数不能检测包含中文的文件名的解决办法
- YII框架的类自动加载机制
- YII框架入门
- php 中关于AES 的使用 ,被友盟搞死了
- 利用phpmyadmin修改mysql的root密码及如何进入修改密码后的phpmyadmin
- 3.5 Zend_Db_Table_Rowset
- PHP中常用的转义函数
- 使用PHP判断Web客户端访问设备类型(手机、平板、PC)的方法
- laravel
- PHP 打印函数之 print print_r
- php curl函数实例