You are here

function xhprof_admin_settings in XHProf 7

Same name and namespace in other branches
  1. 6 xhprof.admin.inc \xhprof_admin_settings()

Administrative settings form for XHProf module.

1 string reference to 'xhprof_admin_settings'
xhprof_menu in ./xhprof.module
Implementation of hook_menu().

File

./xhprof.admin.inc, line 11
Admin page callbacks for the XHProf module.

Code

function xhprof_admin_settings() {
  if (xhprof_extension_check()) {
    $description = t('Profile requests with the xhprof or tideways_xhprof PHP extension.');
  }
  else {
    $description = '<span class="warning">' . t('You must enable the <a href="!url">xhprof or tideways_xhprof PHP extension</a> to use this feature.', array(
      '!url' => url('https://www.drupal.org/node/946182'),
    )) . '</span>';
  }
  $form['xhprof_enabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable profiling of page views and <a href="!drush">drush</a> requests.', array(
      '!drush' => url('http://drush.ws'),
    )),
    '#default_value' => variable_get('xhprof_enabled', FALSE),
    '#description' => $description,
    '#disabled' => !xhprof_extension_check(),
  );
  $form['settings'] = array(
    '#title' => t('Profiling settings'),
    '#type' => 'fieldset',
    '#states' => array(
      'invisible' => array(
        'input[name="xhprof_enabled"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $form['settings']['xhprof_flags_cpu'] = array(
    '#type' => 'checkbox',
    '#title' => t('Include CPU time in profiling output.'),
    '#description' => t('Tracking CPU time adds some overhead. You may consider disabling this when debugging an issue that is not I/O related.'),
    '#default_value' => variable_get('xhprof_flags_cpu', TRUE),
  );
  $form['settings']['xhprof_flags_memory'] = array(
    '#type' => 'checkbox',
    '#title' => t('Include memory usage in profiling output.'),
    '#description' => t('Tracking memory adds some overhead, but not as much as CPU.'),
    '#default_value' => variable_get('xhprof_flags_memory', TRUE),
  );
  $form['settings']['xhprof_disable_admin_paths'] = array(
    '#type' => 'checkbox',
    '#title' => t('Disable profiling of admin pages'),
    '#default_value' => variable_get('xhprof_disable_admin_paths', TRUE),
  );
  if (module_exists('admin_menu')) {
    $form['settings']['xhprof_disable_admin_menu_paths'] = array(
      '#type' => 'checkbox',
      '#title' => t('Disable profiling of Admin-Menu paths'),
      '#description' => t('The Admin-Menu module is installed, check this setting to avoid profiling the admin-menu XHR requests.'),
      '#default_value' => variable_get('xhprof_disable_admin_menu_paths', TRUE),
    );
  }
  $form['settings']['xhprof_interval'] = array(
    '#type' => 'textfield',
    '#title' => 'Profiling interval',
    '#default_value' => variable_get('xhprof_interval', ''),
    '#description' => t('The approximate number of requests between XHProf samples. Leave empty to profile all requests'),
  );
  $options = drupal_map_assoc(xhprof_get_classes());
  $form['settings']['xhprof_default_class'] = array(
    '#type' => 'radios',
    '#title' => t('XHProf storage'),
    '#default_value' => variable_get('xhprof_default_class', 'XHProfRunsFile'),
    '#options' => $options,
    '#description' => t('Choose an XHProf runs class.'),
  );
  return system_settings_form($form);
}