You are here

function xhprof_xhprof_enable in XHProf 7

Same name and namespace in other branches
  1. 6 xhprof.module \xhprof_xhprof_enable()

Conditionally enable XHProf profiling.

1 call to xhprof_xhprof_enable()
xhprof_boot in ./xhprof.module
Implementation of hook_boot(). Runs even for cached pages.

File

./xhprof.module, line 89

Code

function xhprof_xhprof_enable() {
  if (xhprof_is_enabled()) {
    xhprof_require();

    // @todo: consider a variable per-flag instead.
    $flags = 0;

    // Workaround for segmentation fault error.
    // @see https://bugs.php.net/bug.php?id=65345
    if (version_compare(PHP_VERSION, '5.5.0', '>=')) {
      $flags = $flags + XHPROF_FLAGS_NO_BUILTINS;
    }
    if (variable_get('xhprof_flags_cpu', TRUE)) {
      $flags = $flags + XHPROF_FLAGS_CPU;
    }
    if (variable_get('xhprof_flags_memory', TRUE)) {
      $flags = $flags + XHPROF_FLAGS_MEMORY;
    }
    xhprof_enable($flags);
    return TRUE;
  }
  else {
    return FALSE;
  }
}