<?php
// With Drupal
// Add bottom at settings.php, shared by Andy Truong
if (extension_loaded('xhprof')) {
define('XHPROF_KEY', 'profile');
define('XHPROF_ROOT', '/Users/mrsinguyen/Workspaces/www/xhprof');
define('XHPROF_DOMAIN', 'localhost/xhprof/xhprof_html');
define('XHPROF_SOURCE', $_SERVER['SERVER_NAME']);
define('XHPROF_FLAGS', XHPROF_FLAGS_NO_BUILTINS | XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY);
define('XHPROF_SYMBOL', 'menu_execute_active_handler');
function user_init() {
if (!empty($_GET[XHPROF_KEY])) {
require_once XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php";
require_once XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php";
xhprof_enable(XHPROF_FLAGS);
}
}
function system_exit() {
if (!empty($_GET[XHPROF_KEY])) {
$id = (new XHProfRuns_Default())->save_run(xhprof_disable(), XHPROF_SOURCE);
echo sprintf(
'<a href="//%s/?symbol=%s&source=%s&run=%s">%s</a>',
XHPROF_DOMAIN, XHPROF_SYMBOL, XHPROF_SOURCE, $id, "XHProf #{$id}"
);
}
}
}