Skip to content

Instantly share code, notes, and snippets.

@peterlozano
Last active September 25, 2015 08:27
Show Gist options
  • Save peterlozano/892416 to your computer and use it in GitHub Desktop.
Save peterlozano/892416 to your computer and use it in GitHub Desktop.
Enable and dump xhprof
$path = '/usr/share/php';
include_once $path . '/xhprof_lib/utils/xhprof_lib.php';
include_once $path . '/xhprof_lib/utils/xhprof_runs.php';
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
// YOUR CODE HERE
$namespace = 'app_namespace';
$xhprof_data = xhprof_disable();
$xhprof_runs = new XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, $namespace);
$xhprof_url = 'http://domain.local';
$url = $xhprof_url . "/index.php?run=$run_id&source=$namespace";
print t('<a href="@xhprof">XHProf output</a>. ', array('@xhprof' => $url));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment