Add benchmark data to AJAXProxyAction response
authorMatthias Schmidt <gravatronics@live.com>
Sat, 4 Oct 2014 09:54:46 +0000 (11:54 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 4 Oct 2014 09:54:46 +0000 (11:54 +0200)
wcfsetup/install/files/lib/action/AJAXProxyAction.class.php

index 24399108ded74ed05168a390eb8563762db08e60..cd34bd1201a2ce0d757fcb60db5c282c30d1e3ef 100644 (file)
@@ -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();
+       }
 }