function xhprof_is_enabled in XHProf 6
Same name and namespace in other branches
- 7 xhprof.module \xhprof_is_enabled()
Check whether XHProf should be enabled for the current request.
2 calls to xhprof_is_enabled()
- xhprof_shutdown in ./
xhprof.module - See xhprof_start() which registers this function as a shutdown function.
- xhprof_xhprof_enable in ./
xhprof.module - Conditionally enable XHProf profiling.
File
- ./
xhprof.module, line 98
Code
function xhprof_is_enabled() {
$enabled = FALSE;
if (extension_loaded('xhprof') && variable_get('xhprof_enabled', FALSE)) {
$enabled = TRUE;
$path = isset($_GET['q']) ? $_GET['q'] : '';
// Although arg() function can be used, it is not available at hook_boot(), where this function is used.
if (preg_match('/^admin/', $path) && variable_get('xhprof_disable_admin_paths', TRUE)) {
$enabled = FALSE;
}
else {
$interval = variable_get('xhprof_interval', 1);
if ($interval && mt_rand(1, $interval) % $interval != 0) {
$enabled = FALSE;
}
}
}
return $enabled;
}