added performance reports for long loops

This commit is contained in:
kremsy 2017-05-10 11:07:45 +02:00
parent 7b3d5e4659
commit 7c74baf9d2
5 changed files with 15 additions and 4 deletions

View File

@ -4,6 +4,7 @@ namespace ManiaControl\Callbacks;
use ManiaControl\General\UsageInformationAble; use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait; use ManiaControl\General\UsageInformationTrait;
use ManiaControl\Logger;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
/** /**
@ -230,9 +231,19 @@ class CallbackManager implements UsageInformationAble {
} }
// Handle callbacks // Handle callbacks
$timings = array();
$startTime = microtime(true);
$callbacks = $this->maniaControl->getClient()->executeCallbacks(); $callbacks = $this->maniaControl->getClient()->executeCallbacks();
$timings["executeCallbacks"] = microtime(true) - $startTime;
foreach ($callbacks as $callback) { foreach ($callbacks as $callback) {
$time1 = microtime(true);
$this->handleCallback($callback); $this->handleCallback($callback);
$timings[$callback[0]] = microtime(true) - $time1;
}
if($fulltime = ((microtime(true) - $startTime) > 1)){
$this->maniaControl->getErrorHandler()->triggerDebugNotice(json_encode(array("Long Loop Detected: " .$fulltime, $timings)));
} }
} }

View File

@ -55,7 +55,7 @@ class LibXmlRpcCallbacks implements CallbackListener {
*/ */
public function handleScriptCallback($name, $data) { public function handleScriptCallback($name, $data) {
if (!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)) { if (!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)) {
//return; //Leave that disabled while testing/implementing Callbacks return; //Leave that disabled while testing/implementing Callbacks
} }
switch ($name) { switch ($name) {
//New callbacks //New callbacks

View File

@ -73,7 +73,7 @@ class ShootManiaCallbacks implements CallbackListener {
*/ */
public function handleScriptCallbacks($name, $data) { public function handleScriptCallbacks($name, $data) {
if (!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)) { if (!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)) {
//return; //Leave that disabled while testing/implementing Callbacks return; //Leave that disabled while testing/implementing Callbacks
} }
switch ($name) { switch ($name) {
//MP4 New Callbacks //MP4 New Callbacks

View File

@ -51,7 +51,7 @@ class TrackManiaCallbacks implements CallbackListener {
*/ */
public function handleScriptCallbacks($name, $data) { public function handleScriptCallbacks($name, $data) {
if (!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)) { if (!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)) {
//return; //Leave that disabled while testing/implementing Callbacks return; //Leave that disabled while testing/implementing Callbacks
} }
switch ($name) { switch ($name) {
case Callbacks::TM_SCORES: case Callbacks::TM_SCORES:

View File

@ -323,7 +323,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
$playerQuad->addTooltipLabelFeature($descriptionLabel, $description); $playerQuad->addTooltipLabelFeature($descriptionLabel, $description);
} }
if ($this->maniaControl->getServer()->isTeamMode()) { if ($this->maniaControl->getServer()->getScriptManager()->modeIsTeamMode()) {
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM)) { if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM)) {
// Force to Red-Team Quad // Force to Red-Team Quad
$redQuad = new Quad_Emblems(); $redQuad = new Quad_Emblems();