From 9b714acb559fc14f493b4433d17102938a5c4af5 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Tue, 9 Feb 2021 23:52:35 +0900 Subject: [PATCH] Show memory usage in debug panel --- classes/display/DisplayHandler.class.php | 1 + common/framework/debug.php | 1 + common/js/debug.js | 1 + 3 files changed, 3 insertions(+) diff --git a/classes/display/DisplayHandler.class.php b/classes/display/DisplayHandler.class.php index 0d2fa3cb2..ad104e244 100644 --- a/classes/display/DisplayHandler.class.php +++ b/classes/display/DisplayHandler.class.php @@ -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) . '}'; diff --git a/common/framework/debug.php b/common/framework/debug.php index 61a864e1e..31494f4c2 100644 --- a/common/framework/debug.php +++ b/common/framework/debug.php @@ -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), diff --git a/common/js/debug.js b/common/js/debug.js index a715bf5a9..c963eb7be 100644 --- a/common/js/debug.js +++ b/common/js/debug.js @@ -82,6 +82,7 @@ $(function() { var metadata = $('').appendTo(entry); metadata.append($('
  • ').text('Request: ' + data.request.method + (data.request.method !== "GET" ? (' - ' + data.request.size + ' bytes') : ""))); metadata.append($('
  • ').text('Response: ' + data.response.method + ' - ' + data.response.size + ' bytes')); + metadata.append($('
  • ').text('Memory Usage: ' + (data.memory ? XE.filesizeFormat(data.memory) : 'unknown'))); metadata.append($('
  • ').text('Total Time: ' + data.timing.total)); metadata.append($('
  • ').text('Query Time: ' + data.timing.db_query));