Skip to content

Commit

Permalink
Support for listing runs based on a patch from scoates
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott MacVicar committed Apr 9, 2010
1 parent 9cd7344 commit 5cccb66
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions xhprof_lib/display/xhprof.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
18 changes: 17 additions & 1 deletion xhprof_lib/utils/xhprof_runs.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,15 @@ 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();
}

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;
Expand Down Expand Up @@ -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 "<hr/>Existing runs:\n<ul>\n";
foreach (glob("{$this->dir}/*.{$this->suffix}") as $file) {
list($run,$source) = explode('.', basename($file));
echo '<li><a href="' . htmlentities($_SERVER['SCRIPT_NAME'])
. '?run=' . htmlentities($run) . '&source='
. htmlentities($source) . '">'
. htmlentities(basename($file)) . "</a><small> "
. date("Y-m-d H:i:s", filemtime($file)) . "</small></li>\n";
}
echo "</ul>\n";
}
}
}

0 comments on commit 5cccb66

Please sign in to comment.