Open main menu

Changes

1,945 bytes added ,  19:37, 12 February 2018
Created page with "== History == Originally developed at Facebook, XHProf was open sourced in Mar, 2009. It was added to PHP's PECL, and the Facebook website stopped carrying it ~2014 The "sou..."
== History ==
Originally developed at Facebook, XHProf was open sourced in Mar, 2009.

It was added to PHP's PECL, and the Facebook website stopped carrying it ~2014

The "source" lives at Evan Priestley's <ref>creator of Phabricator</ref> [https://github.com/phacility/xhprof/ GitHub] where there have been 87 commits between 2009 and 2015. There haven't been any commits since Feb. 2015 (as of Feb. 2018). The relationship between the GitHub source and the PECL package is unclear<ref>https://github.com/phacility/xhprof/pull/66</ref>

Due to changes in PHP in the 7.0 release, there have been several forks to add PHP 7 support.
# https://github.com/longxinH/xhprof
# [https://tideways.io/profiler/xhprof-for-php7 Tideways] is one option, with commercial support and a cloud service.


== TLDR; ==
<ref>https://github.com/phacility/xhprof/issues/82#issuecomment-294003346</ref>
<source lang="bash">
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);
</source>

Your code:
<source lang="php">
$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
</source>

[[Category:Debugging]]
[[Category:Profiling]]
[[Category:Development]]
[[Category:PHP]]
[[Category:QualityBox]]