Linux下PHP7使用xhprof分析性能

14 篇文章 0 订阅
7 篇文章 0 订阅

PECL(http://pecl.php.net/package/xhprof)上提供的最新扩展并不支持php7版本。

如果想为php7使用xhprof进行性能分析的话请参考https://github.com/Yaoguais/phpng-xhprof所介绍的方法进行编译安装。

Installation

git clone git@github.com:Yaoguais/phpng-xhprof.git ./xhprof
cd xhprof
phpize
./configure
make clean && make && make test && sudo make install

Then add the configuration into php.ini

[xhprof]
extension = phpng_xhprof.so
xhprof.output_dir = /tmp/xhprof

If you compiled PHP7 from source code, then

git clone git@github.com:Yaoguais/phpng-xhprof.git ./xhprof
cd xhprof
/path/to/php7/bin/phpize
./configure --with-php-config=/path/to/php7/bin/php-config
make clean && make && make test && sudo make install

Then add the profile code

xhprof_enable();
// your code
// ...
file_put_contents((ini_get('xhprof.output_dir') ? : '/tmp') . '/' . uniqid() . '.xhprof.xhprof', serialize(xhprof_disable()));

Test

There are 12 test cases, the extension by 11,and the rest can not be due to the result of the PHP core,which is call_user_function family of functions.

You can use "make test" command to test the extension,and there are also simple test examples.

/path/to/php7/bin/php diff/enable.php
ls -l diff

Notice

This extension replaces the PHP core, so when you use other extensions like xdebug or phpdbg,which might be impaired.

You should add the phpng-xhprof configuration options to the php.ini of the bottom,and this is due to PHP 's startup sequence resulting from extension.



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值