From 5cccb661c1dec53755930ad0695369761427c3ef Mon Sep 17 00:00:00 2001 From: Scott MacVicar Date: Thu, 8 Apr 2010 18:52:06 -0700 Subject: [PATCH] Support for listing runs based on a patch from scoates --- xhprof_lib/display/xhprof.php | 3 +++ xhprof_lib/utils/xhprof_runs.php | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/xhprof_lib/display/xhprof.php b/xhprof_lib/display/xhprof.php index 62c7cbaf..b6a7306e 100644 --- a/xhprof_lib/display/xhprof.php +++ b/xhprof_lib/display/xhprof.php @@ -1432,5 +1432,8 @@ function displayXHProfReport($xhprof_runs_impl, $url_params, $source, } else { echo "No XHProf runs specified in the URL."; + if (method_exists($xhprof_runs_impl, 'list_runs')) { + $xhprof_runs_impl->list_runs(); + } } } diff --git a/xhprof_lib/utils/xhprof_runs.php b/xhprof_lib/utils/xhprof_runs.php index b95d82fd..c12f77cb 100644 --- a/xhprof_lib/utils/xhprof_runs.php +++ b/xhprof_lib/utils/xhprof_runs.php @@ -68,6 +68,7 @@ public function save_run($xhprof_data, $type, $run_id = null); class XHProfRuns_Default implements iXHProfRuns { private $dir = ''; + private $suffix = 'xhprof'; private function gen_run_id($type) { return uniqid(); @@ -75,7 +76,7 @@ private function gen_run_id($type) { private function file_name($run_id, $type) { - $file = "$run_id.$type"; + $file = "$run_id.$type." . $this->suffix; if (!empty($this->dir)) { $file = $this->dir . "/" . $file; @@ -144,4 +145,19 @@ public function save_run($xhprof_data, $type, $run_id = null) { // echo "Saved run in {$file_name}.\nRun id = {$run_id}.\n"; return $run_id; } + + function list_runs() { + if (is_dir($this->dir)) { + echo "
Existing runs:\n\n"; + } + } }