From 2da274267d244deeb116ea7ddcdc10b53f7ff7d4 Mon Sep 17 00:00:00 2001 From: kremsy Date: Wed, 10 May 2017 12:40:00 +0200 Subject: [PATCH] performance report improvement --- core/Callbacks/CallbackManager.php | 9 +++++---- core/ErrorHandler.php | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/Callbacks/CallbackManager.php b/core/Callbacks/CallbackManager.php index 8b97512c..3e59c07b 100644 --- a/core/Callbacks/CallbackManager.php +++ b/core/Callbacks/CallbackManager.php @@ -2,6 +2,7 @@ namespace ManiaControl\Callbacks; +use ManiaControl\ErrorHandler; use ManiaControl\General\UsageInformationAble; use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; @@ -235,15 +236,15 @@ class CallbackManager implements UsageInformationAble { $callbacks = $this->maniaControl->getClient()->executeCallbacks(); $timings["executeCallbacks"] = microtime(true) - $startTime; - foreach ($callbacks as $callback) { + foreach ($callbacks as $key => $callback) { $time1 = microtime(true); $this->handleCallback($callback); - $timings[$callback[0]] = microtime(true) - $time1; + $timings[$key] = array($callback[0], microtime(true) - $time1); } $fullTime = microtime(true) - $startTime; - if ($fullTime > 3) { - $this->maniaControl->getErrorHandler()->triggerDebugNotice(json_encode(array("Long Loop Detected: " . $fullTime , $timings))); + if ($fullTime > ErrorHandler::LONG_LOOP_REPORT_TIME) { + $this->maniaControl->getErrorHandler()->triggerDebugNotice(json_encode(array("Long Loop Detected: " . $fullTime, $timings))); } } diff --git a/core/ErrorHandler.php b/core/ErrorHandler.php index 15a98704..4a064754 100644 --- a/core/ErrorHandler.php +++ b/core/ErrorHandler.php @@ -22,6 +22,7 @@ class ErrorHandler { const MC_DEBUG_NOTICE = 'ManiaControl.DebugNotice'; const SETTING_RESTART_ON_EXCEPTION = 'Automatically restart on Exceptions'; const LOG_SUPPRESSED_ERRORS = false; + const LONG_LOOP_REPORT_TIME = 5; /* * Private properties