欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

Linux下PHP7使用xhprof分析性能 有大用

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.



--------------------- 

作者:FocusOnTech 

来源:CSDN 

原文:https://blog.csdn.net/lvchengbo/article/details/52849179 

版权声明:本文为博主原创文章,转载请附上博文链接!


来自  https://blog.csdn.net/lvchengbo/article/details/52849179

普通分类: