From 26385922b381f9c464e90fb69fc4af8c214f7c49 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sat, 4 Oct 2014 11:54:46 +0200 Subject: [PATCH] Add benchmark data to AJAXProxyAction response --- .../lib/action/AJAXProxyAction.class.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/wcfsetup/install/files/lib/action/AJAXProxyAction.class.php b/wcfsetup/install/files/lib/action/AJAXProxyAction.class.php index 24399108de..cd34bd1201 100644 --- a/wcfsetup/install/files/lib/action/AJAXProxyAction.class.php +++ b/wcfsetup/install/files/lib/action/AJAXProxyAction.class.php @@ -2,6 +2,7 @@ namespace wcf\action; use wcf\data\IStorableObject; use wcf\system\exception\SystemException; +use wcf\system\WCF; use wcf\util\ArrayUtil; use wcf\util\ClassUtil; use wcf\util\StringUtil; @@ -97,4 +98,26 @@ class AJAXProxyAction extends AJAXInvokeAction { } return $response; } + + /** + * @see \wcf\action\AJAXInvokeAction::sendResponse() + */ + protected function sendResponse() { + // add benchmark and debug data + if (ENABLE_BENCHMARK) { + $this->response['benchmark'] = array( + 'executionTime' => WCF::getBenchmark()->getExecutionTime().'s', + 'memoryUsage' => WCF::getBenchmark()->getMemoryUsage(), + 'phpExecution' => StringUtil::formatNumeric((WCF::getBenchmark()->getExecutionTime() - WCF::getBenchmark()->getQueryExecutionTime()) / WCF::getBenchmark()->getExecutionTime() * 100).'%', + 'sqlExecution' => StringUtil::formatNumeric(WCF::getBenchmark()->getQueryExecutionTime() / WCF::getBenchmark()->getExecutionTime() * 100).'%', + 'sqlQueries' => WCF::getBenchmark()->getQueryCount() + ); + + if (ENABLE_DEBUG_MODE) { + $this->response['benchmark']['items'] = WCF::getBenchmark()->getItems(); + } + } + + parent::sendResponse(); + } } -- 2.20.1