You are here

function xhprof_displayXHProfReport in XHProf 7

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

Generate a XHProf Display View given the various URL parameters as arguments. The first argument is an object that implements the iXHProfRuns interface.

Parameters

object $xhprof_runs_impl An object that implements: the iXHProfRuns interface .

array $url_params Array of non-default URL params.:

string $source Category/type of the run. The source in: combination with the run id uniquely determines a profiler run.

string $run run id, or comma separated sequence of: run ids. The latter is used if an aggregate report of the runs is desired.

string $wts Comma separate list of integers.: Represents the weighted ratio in which which a set of runs will be aggregated. [Used only for aggregate reports.]

string $symbol function xhprof_symbol. If non-empty then the: parent/child view of this function xhprof_is displayed. If empty, a flat-profile view of the functions is displayed.

string $run1 Base run id (for diff reports):

string $run2 New run id (for diff reports):

File

./xhprof.inc, line 1398

Code

function xhprof_displayXHProfReport($xhprof_runs_impl, $options) {

  // Extract options: $url_params, $source, $run, $wts, $symbol, $sort, $run1, $run2;
  extract($options);
  if ($run) {

    // specific run to display?
    // run may be a single run or a comma separate list of runs
    // that'll be aggregated. If "wts" (a comma separated list
    // of integral weights is specified), the runs will be
    // aggregated in that ratio.
    //
    $runs_array = explode(",", $run);
    if (isset($_GET['order'])) {
      $sort = xhprof_stat_description($_GET['order'], TRUE);
    }
    if (count($runs_array) == 1) {
      $xhprof_data = $xhprof_runs_impl
        ->get_run($runs_array[0], $source, $description, $sort);
    }
    else {
      if (!empty($wts)) {
        $wts_array = explode(",", $wts);
      }
      else {
        $wts_array = NULL;
      }
      $data = xhprof_aggregate_runs($xhprof_runs_impl, $runs_array, $wts_array, $source, FALSE);
      $xhprof_data = $data['raw'];
      $description = $data['description'];
    }
    $output .= xhprof_profiler_single_run_report($url_params, $xhprof_data, $description, $symbol, $sort, $run);
  }
  elseif ($run1 && $run2) {

    // diff report for two runs
    $xhprof_data1 = $xhprof_runs_impl
      ->get_run($run1, $source, $description1);
    $xhprof_data2 = $xhprof_runs_impl
      ->get_run($run2, $source, $description2);
    $output .= xhprof_profiler_diff_report($url_params, $xhprof_data1, $description1, $xhprof_data2, $description2, $symbol, $sort, $run1, $run2);
  }
  else {
    $output .= "No XHProf runs specified in the URL.";
  }
  return $output;
}