1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-24 18:04:43 +02:00

MDL-73734 core: Use streaming output for perfdebug

This commit is contained in:
Brendan Heywood 2023-08-18 01:23:56 +10:00
parent 072a15ced3
commit 20b8f8f9c9
3 changed files with 24 additions and 3 deletions

@ -1020,6 +1020,7 @@ $string['pathtosassc'] = 'Path to SassC';
$string['pathtosassc_help'] = 'Specifying the location of the SassC binary will switch the SASS compiler from Moodle\'s PHP implementation to SassC. See https://github.com/sass/sassc for more information.';
$string['pcreunicodewarning'] = 'It is strongly recommended to use PCRE PHP extension that is compatible with Unicode characters.';
$string['perfdebug'] = 'Performance info';
$string['perfdebugdeferred'] = 'Waiting until the script ends to show the performance debugging ...';
$string['performance'] = 'Performance';
$string['pgcluster'] = 'PostgreSQL Cluster';
$string['pgclusterdescription'] = 'PostgreSQL version/cluster parameter for command line operations. If you only have one postgresql on your system or you are not sure what this is, leave this blank.';

@ -195,7 +195,7 @@ class core_shutdown_manager {
* Standard shutdown sequence.
*/
protected static function request_shutdown() {
global $CFG;
global $CFG, $OUTPUT;
// Help apache server if possible.
$apachereleasemem = false;
@ -216,6 +216,15 @@ class core_shutdown_manager {
$perf = get_performance_info();
error_log("PERF: " . $perf['txt']);
}
if (MDL_PERFTOFOOT || debugging() || (!empty($CFG->perfdebug) && $CFG->perfdebug > 7)) {
if (NO_OUTPUT_BUFFERING) {
// If the performance footer was deferred then print it now.
if (!CLI_SCRIPT && !WS_SERVER) {
$perf = get_performance_info();
echo $OUTPUT->select_element_for_replace('#perfdebugfooter', $perf['html']);
}
}
}
if (MDL_PERFINC) {
$inc = get_included_files();
$ts = 0;

@ -1512,9 +1512,20 @@ class core_renderer extends renderer_base {
// Provide some performance info if required
$performanceinfo = '';
if (MDL_PERF || (!empty($CFG->perfdebug) && $CFG->perfdebug > 7)) {
$perf = get_performance_info();
if (MDL_PERFTOFOOT || debugging() || (!empty($CFG->perfdebug) && $CFG->perfdebug > 7)) {
$performanceinfo = $perf['html'];
if (NO_OUTPUT_BUFFERING) {
// If the output buffer was off then we render a placeholder and stream the
// performance debugging into it at the very end in the shutdown handler.
$performanceinfo .= html_writer::tag('div',
get_string('perfdebugdeferred', 'admin'),
[
'id' => 'perfdebugfooter',
'style' => 'min-height: 30em',
]);
} else {
$perf = get_performance_info();
$performanceinfo = $perf['html'];
}
}
}