Linux下PHP7使用xhprof分析性能
PECL(http://pecl.php.net/package/xhprof)上提供的最新扩展并不支持php7版本。
如果想为php7使用xhprof进行性能分析的话请参考https://github.com/Yaoguais/phpng-xhprof所介绍的方法进行编译安装。
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()));
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
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.
- 上一篇: xhprof安装使用
- 下一篇: php html_entity_decode使用总结