Show memory usage in debug panel

This commit is contained in:
Kijin Sung 2021-02-09 23:52:35 +09:00
parent 08f8e0ccd4
commit 9b714acb55
3 changed files with 3 additions and 0 deletions

View file

@ -249,6 +249,7 @@ class DisplayHandler extends Handler
$output = substr($output, 0, $body_end_position) . "\n$panel_script\n" . substr($output, $body_end_position);
break;
case 'JSON':
unset($_SESSION['_rx_debug_previous']);
if (preg_match('/^(.+)\}$/', $output, $matches))
{
$output = $matches[1] . ',"_rx_debug":' . json_encode($data) . '}';

View file

@ -776,6 +776,7 @@ class Debug
'method' => \Context::getResponseMethod(),
'size' => \DisplayHandler::$response_size,
),
'memory' => memory_get_peak_usage(),
'timing' => (object)array(
'total' => sprintf('%0.4f sec', microtime(true) - \RX_MICROTIME),
'template' => sprintf('%0.4f sec (count: %d)', $GLOBALS['__template_elapsed__'] ?? 0, $GLOBALS['__TemplateHandlerCalled__'] ?? 0),

View file

@ -82,6 +82,7 @@ $(function() {
var metadata = $('<ul class="debug_metadata"></ul>').appendTo(entry);
metadata.append($('<li></li>').text('Request: ' + data.request.method + (data.request.method !== "GET" ? (' - ' + data.request.size + ' bytes') : "")));
metadata.append($('<li></li>').text('Response: ' + data.response.method + ' - ' + data.response.size + ' bytes'));
metadata.append($('<li></li>').text('Memory Usage: ' + (data.memory ? XE.filesizeFormat(data.memory) : 'unknown')));
metadata.append($('<li></li>').text('Total Time: ' + data.timing.total));
metadata.append($('<li></li>').text('Query Time: ' + data.timing.db_query));