Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions xhprof_lib/utils/xhprof_runs.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,33 @@ public function save_run($xhprof_data, $type, $run_id = null) {

function list_runs() {
if (is_dir($this->dir)) {
echo "<hr/>Existing runs:\n<ul>\n";
echo "<hr/>Existing runs:<br />\n";
$files = glob("{$this->dir}/*.{$this->suffix}");
usort($files, create_function('$a,$b', 'return filemtime($b) - filemtime($a);'));

$sort_function = function($a, $b){
list($tmp,$source_a) = explode('.', basename($a));
list($tmp,$source_b) = explode('.', basename($b));

if ($source_a == $source_b) {
return filemtime($b) - filemtime($a);
}

return $source_a > $source_b;
};

usort($files, $sort_function);

$oldSource=null;

foreach ($files as $file) {
list($run,$source) = explode('.', basename($file));
if ($oldSource != $source) {
if (null !== $oldSource) {
echo "</ul><hr />\n";
}
echo "<b>$source</b><ul>";
$oldSource = $source;
}
echo '<li><a href="' . htmlentities($_SERVER['SCRIPT_NAME'])
. '?run=' . htmlentities($run) . '&source='
. htmlentities($source) . '">'
Expand Down