Skip to content

Instantly share code, notes, and snippets.

@Yanovskiy
Last active August 29, 2015 13:56
Show Gist options
  • Save Yanovskiy/9048355 to your computer and use it in GitHub Desktop.
Save Yanovskiy/9048355 to your computer and use it in GitHub Desktop.
XHProf enable
<?php
if(extension_loaded('xhprof')) {
$utilsPath = '/usr/share/php5-xhprof/xhprof_lib/utils/';
include_once $utilsPath . 'xhprof_lib.php';
include_once $utilsPath . 'xhprof_runs.php';
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
register_shutdown_function(function() {
$profilerNamespace = pathinfo(__FILE__, PATHINFO_FILENAME);
$data = xhprof_disable();
$xhprofRuns = new XHProfRuns_Default();
$xhprofRuns->save_run($data, $profilerNamespace);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment