Difference between revisions of "XHProf"

From Freephile Wiki
Jump to navigation Jump to search
(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...")
 
m (Admin moved page XHProf to XHProf: correct capitalization)
(No difference)

Revision as of 18:38, 12 February 2018

History[edit | edit source]

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 [1]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[2]

Due to changes in PHP in the 7.0 release, there have been several forks to add PHP 7 support.

  1. https://github.com/longxinH/xhprof
  2. Tideways is one option, with commercial support and a cloud service.


TLDR;[edit | edit source]

[3]

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