diff --git a/admin/tool/profiling/index.php b/admin/tool/profiling/index.php
index a5e21d3badfec..e602e44196b01 100644
--- a/admin/tool/profiling/index.php
+++ b/admin/tool/profiling/index.php
@@ -74,12 +74,11 @@
$prevreferences = $DB->get_records_select('profiling',
'url = ? AND runreference = 1 AND timecreated < ?',
array($run->url, $run->timecreated),
- 'timecreated DESC', 'runid', 0, 1);
- $prevrunid = $prevreferences ? reset($prevreferences)->runid : false;
+ 'timecreated DESC', 'runid, runcomment, timecreated', 0, 10);
echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter');
$header = get_string('lastrunof', 'tool_profiling', $script);
echo $OUTPUT->heading($header);
- $table = profiling_print_run($run, $prevrunid);
+ $table = profiling_print_run($run, $prevreferences);
echo $table;
echo $OUTPUT->box_end();
@@ -126,12 +125,11 @@
$prevreferences = $DB->get_records_select('profiling',
'url = ? AND runreference = 1 AND timecreated < ?',
array($run->url, $run->timecreated),
- 'timecreated DESC', 'runid', 0, 1);
- $prevrunid = $prevreferences ? reset($prevreferences)->runid : false;
+ 'timecreated DESC', 'runid, runcomment, timecreated', 0, 10);
echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter');
$header = get_string('summaryof', 'tool_profiling', $run->url);
echo $OUTPUT->heading($header);
- $table = profiling_print_run($run, $prevrunid);
+ $table = profiling_print_run($run, $prevreferences);
echo $table;
echo $OUTPUT->box_end();
diff --git a/admin/tool/profiling/lang/en/tool_profiling.php b/admin/tool/profiling/lang/en/tool_profiling.php
index 4a687f8f279ca..7c80c848c3ac8 100644
--- a/admin/tool/profiling/lang/en/tool_profiling.php
+++ b/admin/tool/profiling/lang/en/tool_profiling.php
@@ -51,5 +51,5 @@
$string['runid'] = 'Run ID';
$string['summaryof'] = 'Summary of {$a}';
$string['viewdetails'] = 'View profiling details';
-$string['viewdiff'] = 'View profiling differences with last reference run';
+$string['viewdiff'] = 'View profiling differences with:';
$string['viewdiffdetails'] = 'View profiling diff details';
diff --git a/lib/xhprof/xhprof_moodle.php b/lib/xhprof/xhprof_moodle.php
index e013c83d28701..02026c6156a20 100644
--- a/lib/xhprof/xhprof_moodle.php
+++ b/lib/xhprof/xhprof_moodle.php
@@ -263,7 +263,14 @@ function profiling_urls($report, $runid, $runid2 = null) {
return $url;
}
-function profiling_print_run($run, $prevrunid = null) {
+/**
+ * Generate the output to print a profiling run including further actions you can then take.
+ *
+ * @param object $run The profiling run object we are going to display.
+ * @param array $prevreferences A list of run objects to list as comparison targets.
+ * @return string The output to display on the screen for this run.
+ */
+function profiling_print_run($run, $prevreferences = null) {
global $CFG, $OUTPUT;
$output = '';
@@ -297,13 +304,28 @@ function profiling_print_run($run, $prevrunid = null) {
// Add link to details
$strviewdetails = get_string('viewdetails', 'tool_profiling');
$url = profiling_urls('run', $run->runid);
- $output.=$OUTPUT->heading('' . $strviewdetails . '', 3, 'main profilinglink');
- // If there is one previous run marked as reference, add link to diff
- if ($prevrunid) {
- $strviewdiff = get_string('viewdiff', 'tool_profiling');
- $url = 'index.php?runid=' . $run->runid . '&runid2=' . $prevrunid . '&listurl=' . urlencode($run->url);
- $output.=$OUTPUT->heading('' . $strviewdiff . '', 3, 'main profilinglink');
+ $output .= $OUTPUT->heading('' . $strviewdetails . '', 3, 'main profilinglink');
+
+ // If there are previous run(s) marked as reference, add link to diff.
+ if ($prevreferences) {
+ $table = new html_table();
+ $table->align = array('left', 'left');
+ $table->head = array(get_string('date'), get_string('runid', 'tool_profiling'), get_string('comment', 'tool_profiling'));
+ $table->tablealign = 'center';
+ $table->attributes['class'] = 'flexible generaltable generalbox';
+ $table->colclasses = array('value', 'value', 'value');
+ $table->data = array();
+
+ $output .= $OUTPUT->heading(get_string('viewdiff', 'tool_profiling'), 3, 'main profilinglink');
+
+ foreach ($prevreferences as $reference) {
+ $url = 'index.php?runid=' . $run->runid . '&runid2=' . $reference->runid . '&listurl=' . urlencode($run->url);
+ $row = array(userdate($reference->timecreated), ''.$reference->runid.'', $reference->runcomment);
+ $table->data[] = $row;
+ }
+ $output .= $OUTPUT->box(html_writer::table($table), 'profilingrunbox', 'profiling_diffs', true);
+
}
// Add link to export this run.
$strexport = get_string('exportthis', 'tool_profiling');