phacility / xhprof

XHProf is a function-level hierarchical profiler for PHP and has a simple HTML based user interface.
http://pecl.php.net/package/xhprof
Apache License 2.0
2.6k stars 924 forks source link

PHP 7 support #82

Closed langemeijer closed 6 years ago

langemeijer commented 8 years ago

With the introduction of PHP 7 the phpapi has changed a bit. As a result xhprof won't compile when phpized with the PHP 7.0 phpize.

Is someone planning to do PHP 7 support?

langemeijer commented 8 years ago

I just stumbled upon https://github.com/RustJason/xhprof/tree/php7 and will try to give it a spin.

kleijnweb commented 8 years ago

@langemeijer how is that working out for you?

langemeijer commented 8 years ago

I have a big number of other extensions to compile before I can do any testing in a staging environment, because my application has a large number of dependencies. I can tell that it compiles correctly on my build system. (debian jessie with php 7.0.2)

rustjson commented 8 years ago

@langemeijer feel free to let me know if you have any issues.

aftabalamdev99 commented 8 years ago

Hello. I am using windows. I want an xhprof profiling tool for php7. Please inform me about xhprof dll release for php7. I am not expert in xhprof but I am learning it. Please release xhprof as soon as possible for windows user.

senvys commented 8 years ago

xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY); Do not display CPU and memory information,why?

udoless commented 8 years ago

Hi, xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY) doesn't work in php7, is it a bug?

lav45 commented 8 years ago

@udoless

xhprof_enable(XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY);
poolerMF commented 7 years ago

@udoless , @LAV45 it doesn't matter if "|" or "+"

const XHPROF_FLAGS_NO_BUILTINS = 1; const XHPROF_FLAGS_CPU = 2; const XHPROF_FLAGS_MEMORY = 4;

so you can call xhprof_enable(7) .. or xhprof_enable(6), you do not need to use constants

@udoless try to use https://github.com/longxinH/xhprof ... it's working for me (ubuntu 16.04, php7)

git clone https://github.com/longxinH/xhprof
cd xhprof/extension
phpize
./configure --with-php-config=/usr/bin/php-config7.0
sudo make && sudo make install
mallardduck commented 7 years ago

The fork from @RustJason seems to work for me on Arch with PHP7

cr-solutions commented 7 years ago

I have the same problem, no display of CPU and memory (Debian Jessie with PHP 7.1) If I use the fork master I get an error on make and with the fork https://github.com/RustJason/xhprof/tree/php7 I also not see CPU and memory

But version https://github.com/longxinH/xhprof seems working

lsa-github commented 7 years ago

Its working. ubuntu 16.04 nginx php7.0-fpm

git clone https://github.com/longxinH/xhprof
cd xhprof/extension
phpize (if is not found command then sudo apt-get install php7.0-dev)
./configure --with-php-config=/usr/bin/php-config7.0
sudo make && sudo make install

sudo vim /etc/php/7.0/fpm/php.ini
(if console app sudo vim /etc/php/7.0/cli/php.ini)
[xhprof]
extension=xhprof.so
xhprof.output_dir="/tmp/xhprof"

sudo service php7.0-fpm restart

your script.php

xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);

....
#your code
....

$xhprof_data = xhprof_disable();
include_once  '/var/www/xhprof/xhprof_lib/utils/xhprof_lib.php';
include_once  '/var/www/xhprof/xhprof_lib/utils/xhprof_runs.php';
$xhprof_runs = new \XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, 'your_project');
echo "<a href='http://xhprof/index.php?run={$run_id}&source=your_project' target='_blank'>profile</a>";
#http://xhprof is my localhost

result Overall Summary Total Incl. Wall Time (microsec): 9,412 microsecs Total Incl. CPU (microsecs): 4,000 microsecs Total Incl. MemUse (bytes): 1,619,896 bytes Total Incl. PeakMemUse (bytes): 1,494,016 bytes Number of Function Calls: 3,471 ...

sankalpsans commented 6 years ago

For those looking, here are the steps for PHP 7.1 (modified the snippets shared by @Slihotin )

git clone https://github.com/longxinH/xhprof
cd xhprof/extension
phpize (if is not found command then sudo apt-get install php7.1-dev)
./configure --with-php-config=/usr/bin/php-config7.1
sudo make && sudo make install

Then modify the ini files /etc/php/7.1/fpm/php.ini or the module files separately if that's how you do it to add the following lines

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

sudo service php7.1-fpm restart
katzien commented 6 years ago

I came across this recently - https://tideways.io/profiler/xhprof-for-php7

andypost commented 6 years ago

Btw new release of xdebug mostly replacement for xhprof now

ihorvorotnov commented 6 years ago

@andypost in what way? I'm following xdebug 2.6 development, not sure what you mean though.

andypost commented 6 years ago

@ihorvorotnov I see no reason in xhprof after 2.6 release of xdebug fixed memory usage in profiling

ihorvorotnov commented 6 years ago

@andypost What about comparing multiple runs? Also xdebug is much more resource intensive and shouldn’t be used on production. Both have a bit different purposes.

andypost commented 6 years ago

Good point about live! OTOH maybe easy to make xdebug less involved in eating cpu or do that on demand ... cos here only 2 forks & tideways vs blackfire

andypost commented 6 years ago

After checking code in new https://github.com/tideways/php-xhprof-extension/tree/v5.0-beta1 I think it looks much cleaner comparing to https://github.com/longxinH/xhprof/tree/master/extension

epriestley commented 6 years ago

https://secure.phabricator.com/T9805#233567