Skip to content

Commit

Permalink
Merge branch 'MDL-40793_profile_compare' of https://github.com/mr-rus…
Browse files Browse the repository at this point in the history
  • Loading branch information
danpoltawski committed Jul 23, 2013
2 parents 9ced78b + 5f052b5 commit 35c1179
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 15 deletions.
10 changes: 4 additions & 6 deletions admin/tool/profiling/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion admin/tool/profiling/lang/en/tool_profiling.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
38 changes: 30 additions & 8 deletions lib/xhprof/xhprof_moodle.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand Down Expand Up @@ -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('<a href="' . $url . '" onclick="javascript:window.open(' . "'" . $url . "'" . ');' .
'return false;"' . ' title="">' . $strviewdetails . '</a>', 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 . '&amp;runid2=' . $prevrunid . '&amp;listurl=' . urlencode($run->url);
$output.=$OUTPUT->heading('<a href="' . $url . '" title="">' . $strviewdiff . '</a>', 3, 'main profilinglink');
$output .= $OUTPUT->heading('<a href="' . $url . '" onclick="javascript:window.open(' . "'" . $url . "'" . ');' .
'return false;"' . ' title="">' . $strviewdetails . '</a>', 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 . '&amp;runid2=' . $reference->runid . '&amp;listurl=' . urlencode($run->url);
$row = array(userdate($reference->timecreated), '<a href="' . $url . '" title="">'.$reference->runid.'</a>', $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');
Expand Down

0 comments on commit 35c1179

Please sign in to comment.