Skip to content

Commit

Permalink
feat(debug): Measure notification time
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Dec 14, 2023
1 parent 99d8350 commit 0e368dc
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/Push.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ public function pushToDevice(int $id, INotification $notification, ?OutputInterf
return;
}

$start = microtime(true);
$user = $this->createFakeUserObject($notification->getUser());

if (!array_key_exists($notification->getUser(), $this->userStatuses)) {
Expand Down Expand Up @@ -304,6 +305,7 @@ public function pushToDevice(int $id, INotification $notification, ?OutputInterf
$language = $this->l10nFactory->getUserLanguage($user);
$this->printInfo('Language is set to ' . $language);

$start1 = microtime(true);
try {
$this->notificationManager->setPreparingPushNotification(true);
$notification = $this->notificationManager->prepare($notification, $language);
Expand All @@ -312,6 +314,10 @@ public function pushToDevice(int $id, INotification $notification, ?OutputInterf
} finally {
$this->notificationManager->setPreparingPushNotification(false);
}
$end1 = microtime(true);
if (isset($_SERVER['REQUEST_URI']) && str_contains($_SERVER['REQUEST_URI'], 'apps/spreed/api/v4/call/')) {
error_log('[' . get_class($this) . '] Preparing Notification #' . $id . ' - ' . ($end1 - $start1));
}

$userKey = $this->keyManager->getKey($user);

Expand Down Expand Up @@ -353,6 +359,11 @@ public function pushToDevice(int $id, INotification $notification, ?OutputInterf
}
}

$end = microtime(true);
if (isset($_SERVER['REQUEST_URI']) && str_contains($_SERVER['REQUEST_URI'], 'apps/spreed/api/v4/call/')) {
error_log('[' . get_class($this) . '] Total Notification for ' . $notification->getUser() . ' - ' . ($end - $start));
}

if (!$this->deferPayloads) {
$this->sendNotificationsToProxies();
}
Expand Down

0 comments on commit 0e368dc

Please sign in to comment.