You are here

function theme_xhprof_run_table in XHProf 6

Same name and namespace in other branches
  1. 7 xhprof.module \theme_xhprof_run_table()

Theme function to display list of XHProf function calls.

1 theme call to theme_xhprof_run_table()
xhprof_full_report in ./xhprof.inc
Generates a tabular report for all functions. This is the top-level report.

File

./xhprof.module, line 417

Code

function theme_xhprof_run_table($stats, $totals, $url_params, $title, $flat_data, $limit) {
  global $base_path;

  // Table attributes
  $attributes = array(
    'id' => 'xhprof-run-table',
  );
  $output = '';

  // Headers.
  $header = array();
  foreach ($stats as $stat) {
    $desc = xhprof_stat_description($stat);
    if (array_key_exists($stat, xhprof_sortable_columns($stat))) {
      if (isset($_GET['sort']) && $stat == $_GET['sort']) {
        $header_desc = l(t($desc), $_GET['q'], array(
          'query' => array(
            'sort' => $stat,
          ),
          t($desc),
        ));
        $header[] = array(
          'data' => t($header_desc) . theme('tablesort_indicator', 'desc'),
        );
      }
      else {
        $header_desc = l(t($desc), $_GET['q'], array(
          'query' => array(
            'sort' => $stat,
          ),
          t($desc),
        ));
        $header[] = array(
          'data' => t($header_desc),
        );
      }
    }
    else {
      $header[] = array(
        'data' => t($desc),
      );
    }
  }
  $path = '/reports/xhprof/' . $url_params['run'] . '/symbol/';

  // Table rows
  $rows = array();
  $trail = menu_get_active_trail();
  $i = 0;
  foreach ($flat_data as $data) {
    $row = array(
      array(
        'data' => l($data["fn"], $trail[1]["href"] . $path . $data["fn"]),
      ),
      array(
        'data' => xhprof_print_num($data['ct'], NULL, TRUE),
        'class' => 'xhprof_micro',
      ),
      array(
        'data' => xhprof_print_pct($data['ct'], $totals['ct'], TRUE),
        'class' => 'xhprof_percent',
      ),
      array(
        'data' => xhprof_print_num($data['wt'], NULL, TRUE),
        'class' => 'xhprof_micro',
      ),
      array(
        'data' => xhprof_print_pct($data['wt'], $totals['wt'], TRUE),
        'class' => 'xhprof_percent',
      ),
      array(
        'data' => xhprof_print_num($data['excl_wt'], NULL, TRUE),
        'class' => 'xhprof_micro',
      ),
      array(
        'data' => xhprof_print_pct($data['excl_wt'], $totals['wt'], TRUE),
        'class' => 'xhprof_percent',
      ),
      array(
        'data' => xhprof_print_num($data['cpu'], NULL, TRUE),
        'class' => 'xhprof_micro',
      ),
      array(
        'data' => xhprof_print_pct($data['cpu'], $totals['cpu'], TRUE),
        'class' => 'xhprof_percent',
      ),
      array(
        'data' => xhprof_print_num($data['excl_cpu'], NULL, TRUE),
        'class' => 'xhprof_micro',
      ),
      array(
        'data' => xhprof_print_pct($data['excl_cpu'], $totals['cpu'], TRUE),
        'class' => 'xhprof_percent',
      ),
      array(
        'data' => xhprof_print_num($data['mu'], NULL, TRUE),
        'class' => 'xhprof_micro',
      ),
      array(
        'data' => xhprof_print_pct($data['mu'], $totals['mu'], TRUE),
        'class' => 'xhprof_percent',
      ),
      array(
        'data' => xhprof_print_num($data['excl_mu'], NULL, TRUE),
        'class' => 'xhprof_micro',
      ),
      array(
        'data' => xhprof_print_pct($data['excl_mu'], $totals['mu'], TRUE),
        'class' => 'xhprof_percent',
      ),
      array(
        'data' => xhprof_print_num($data['pmu'], NULL, TRUE),
        'class' => 'xhprof_micro',
      ),
      array(
        'data' => xhprof_print_pct($data['pmu'], $totals['pmu'], TRUE),
        'class' => 'xhprof_percent',
      ),
      array(
        'data' => xhprof_print_num($data['excl_pmu'], NULL, TRUE),
        'class' => 'xhprof_micro',
      ),
      array(
        'data' => xhprof_print_pct($data['excl_pmu'], $totals['pmu'], TRUE),
        'class' => 'xhprof_percent',
      ),
    );
    $rows[] = $row;
    $i++;
    if ($limit && $i >= $limit) {
      break;
    }
  }
  $size = count($flat_data);
  if (!$limit) {

    // no limit
    $limit = $size;
    $display_link = "";
  }
  else {
    $display_link = l(" [ <strong class=bubble>display all </strong>]", $_GET['q'], array(
      'query' => xhprof_array_set($url_params, 'all', 1),
      'html' => TRUE,
    ));
  }
  $output .= "<h3 align=center>{$title} {$display_link}</h3><br>";
  $output .= theme('table', $header, $rows, $attributes);
  return $output;
}