performance report improvement

This commit is contained in:
kremsy 2017-05-10 12:40:00 +02:00
parent df31eb7b14
commit 2da274267d
2 changed files with 6 additions and 4 deletions

View File

@ -2,6 +2,7 @@
namespace ManiaControl\Callbacks; namespace ManiaControl\Callbacks;
use ManiaControl\ErrorHandler;
use ManiaControl\General\UsageInformationAble; use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait; use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
@ -235,15 +236,15 @@ class CallbackManager implements UsageInformationAble {
$callbacks = $this->maniaControl->getClient()->executeCallbacks(); $callbacks = $this->maniaControl->getClient()->executeCallbacks();
$timings["executeCallbacks"] = microtime(true) - $startTime; $timings["executeCallbacks"] = microtime(true) - $startTime;
foreach ($callbacks as $callback) { foreach ($callbacks as $key => $callback) {
$time1 = microtime(true); $time1 = microtime(true);
$this->handleCallback($callback); $this->handleCallback($callback);
$timings[$callback[0]] = microtime(true) - $time1; $timings[$key] = array($callback[0], microtime(true) - $time1);
} }
$fullTime = microtime(true) - $startTime; $fullTime = microtime(true) - $startTime;
if ($fullTime > 3) { if ($fullTime > ErrorHandler::LONG_LOOP_REPORT_TIME) {
$this->maniaControl->getErrorHandler()->triggerDebugNotice(json_encode(array("Long Loop Detected: " . $fullTime , $timings))); $this->maniaControl->getErrorHandler()->triggerDebugNotice(json_encode(array("Long Loop Detected: " . $fullTime, $timings)));
} }
} }

View File

@ -22,6 +22,7 @@ class ErrorHandler {
const MC_DEBUG_NOTICE = 'ManiaControl.DebugNotice'; const MC_DEBUG_NOTICE = 'ManiaControl.DebugNotice';
const SETTING_RESTART_ON_EXCEPTION = 'Automatically restart on Exceptions'; const SETTING_RESTART_ON_EXCEPTION = 'Automatically restart on Exceptions';
const LOG_SUPPRESSED_ERRORS = false; const LOG_SUPPRESSED_ERRORS = false;
const LONG_LOOP_REPORT_TIME = 5;
/* /*
* Private properties * Private properties