You are here

function performance_settings in Performance Logging and Monitoring 5

1 string reference to 'performance_settings'
performance_menu in ./performance.module

File

./performance.module, line 53

Code

function performance_settings() {
  $options = array(
    0 => t('Disabled'),
    1 => t('Enabled'),
  );
  if (function_exists('apc_store')) {
    drupal_set_message(t('APC is enabled. It is reasonably safe to enable summary logging on live sites.'));
  }
  else {
    drupal_set_message(t('APC is not enabled. It is <strong>not</strong> safe to enable summary logging to the database on live sites.'), 'error');
  }
  $form['mode'] = array(
    '#type' => 'fieldset',
    '#title' => t('Logging mode'),
    '#collapsible' => TRUE,
  );
  $form['mode']['performance_detail'] = array(
    '#type' => 'select',
    '#title' => t('Detailed logging'),
    '#default_value' => variable_get('performance_detail', 0),
    '#options' => $options,
    '#description' => t('Log memory usage and page generation times for every page. This logging mode is <strong>not</strong> suitable for large sites, as it can degrade performance severly. It is intended for use by developers, or on a test copy of the site.'),
  );
  $form['mode']['performance_summary_db'] = array(
    '#type' => 'select',
    '#title' => t('Summary logging (DB)'),
    '#default_value' => variable_get('performance_summary_db', 0),
    '#options' => $options,
    '#description' => t('Log summary data, such as average and maximum page generation times and memory usage to the database. This logging mode is <strong>not</strong> suitable for most live sites.'),
  );
  $disabled = TRUE;
  if (function_exists('apc_store')) {
    $disabled = FALSE;
  }
  $form['mode']['performance_summary_apc'] = array(
    '#type' => 'select',
    '#title' => t('Summary logging (APC)'),
    '#default_value' => variable_get('performance_summary_apc', 0),
    '#options' => $options,
    '#disabled' => $disabled,
    '#description' => t('Log summary data, such as average and maximum page generation times and memory usage to APC, if installed. The summary will be stored in APC memory, and hence there is no load on the database. This logging to APC is suitable for most live sites, unless the number of unique page accesses is excessively high.'),
  );
  $form['other'] = array(
    '#type' => 'fieldset',
    '#title' => t('Other'),
    '#collapsible' => TRUE,
  );
  $form['other']['performance_titles'] = array(
    '#type' => 'select',
    '#title' => t('Show titles instead of URLs'),
    '#default_value' => variable_get('performance_titles', 0),
    '#options' => array(
      0 => t('URLs only'),
      1 => t('URLs and Titles as hyperlinks'),
    ),
    '#description' => t('In the reports, show path titles hyperlinked to the URLs, or just the path URLs.'),
  );
  $form['other']['dev_query'] = array(
    '#type' => 'select',
    '#title' => t('Database Query timing and count'),
    '#default_value' => variable_get('dev_query', 0),
    '#options' => $options,
    '#description' => t('Log database timing and count for each page. This is useful to know if the bottleneck is in excessive database query counts, or the time required to execute those queries is high. Please note that this will automatically be enabled and disabled in the settings of the devel module. Also note that enabling this will incurr some memory overhead as query times and the actual query strings are cached in memory as arrays.'),
  );
  $form['other']['performance_threshold_accesses'] = array(
    '#type' => 'select',
    '#title' => t('Accesses threshold'),
    '#default_value' => variable_get('performance_threshold_accesses', 0),
    '#options' => array(
      0,
      1,
      2,
      5,
      10,
    ),
    '#description' => t('When displaying the summary report and using APC, only pages with the number of accesses larger than the specified threshold will be shown. Also, when cron runs, pages with that number of accesses or less will be removed, so as not to overflow APC\'s shared memory. This is useful on a live site with a high volume of hits. On a development site, you probably want this set to 0, so you can see all pages.'),
  );
  return system_settings_form($form);
}