From c753d35baff55419b0e8bcbd04c7872ae06f6f29 Mon Sep 17 00:00:00 2001 From: Akhil Date: Thu, 22 Jun 2023 20:58:05 +0530 Subject: [PATCH 1/3] Added timing logs --- lib/Controller/UserController.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/Controller/UserController.php b/lib/Controller/UserController.php index 975e7aa7..b986db05 100644 --- a/lib/Controller/UserController.php +++ b/lib/Controller/UserController.php @@ -67,35 +67,51 @@ class UserController extends ApiController { */ public function setAccountData(string $token, string $uid, string $email, string $recoveryEmail, string $hmeAlias, string $quota = '1024 MB', bool $tosAccepted = false): DataResponse { $response = new DataResponse(); - if (!$this->checkAppCredentials($token)) { $response->setStatus(401); return $response; } + $startTime = time(); if (!$this->userService->userExists($uid)) { $response->setStatus(404); return $response; } - + $existsTime = time() - $startTime; $user = $this->userService->getUser($uid); if (is_null($user)) { $response->setStatus(404); return $response; } + $getUserTime = time() - $existsTime; $user->setEMailAddress($email); + $setEmailTime = time() - $getUserTime; $user->setQuota($quota); + $setQuotaTime = time() - $setEmailTime; $this->config->setUserValue($uid, 'terms_of_service', 'tosAccepted', intval($tosAccepted)); + $setTosTime = time() - $setQuotaTime; $recoveryEmailUpdated = $this->userService->setRecoveryEmail($uid, $recoveryEmail); if (!$recoveryEmailUpdated) { return $this->getErrorResponse($response, 'error_setting_recovery', 400); } + $setRecoveryTime = time() - $setTosTime; $hmeAliasAdded = $this->userService->addHMEAliasInConfig($uid, $hmeAlias); if (!$hmeAliasAdded) { return $this->getErrorResponse($response, 'error_adding_hme_alias', 400); } + $setHmeTime = time() - $setRecoveryTime; + $this->logger->error( + 'setAccountData-benchmark: starting at: ' . $startTime + . ' userExists time: ' . $existsTime + . ' getUser time: ' . $getUserTime + . ' setEmail time: ' . $setEmailTime + . ' setTos time: ' . $setTosTime + . ' setRecovery time: ' . $setRecoveryTime + . ' setHme time: ' . $setHmeTime + ); + return $response; } -- GitLab From ac2c5014b1b8715b58cd352d56e747c00b0cfa28 Mon Sep 17 00:00:00 2001 From: Akhil Date: Thu, 22 Jun 2023 21:00:58 +0530 Subject: [PATCH 2/3] add setQuota time --- lib/Controller/UserController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Controller/UserController.php b/lib/Controller/UserController.php index b986db05..159f86d9 100644 --- a/lib/Controller/UserController.php +++ b/lib/Controller/UserController.php @@ -106,6 +106,7 @@ class UserController extends ApiController { 'setAccountData-benchmark: starting at: ' . $startTime . ' userExists time: ' . $existsTime . ' getUser time: ' . $getUserTime + . ' setQuota time: ' . $setQuotaTime . ' setEmail time: ' . $setEmailTime . ' setTos time: ' . $setTosTime . ' setRecovery time: ' . $setRecoveryTime -- GitLab From 481bc404b0b43995583aef4e0cee7c3c2a349fe4 Mon Sep 17 00:00:00 2001 From: Akhil Date: Thu, 22 Jun 2023 21:17:55 +0530 Subject: [PATCH 3/3] Fix time compute --- lib/Controller/UserController.php | 45 +++++++++++++++++++------------ 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/lib/Controller/UserController.php b/lib/Controller/UserController.php index 159f86d9..eedb6e77 100644 --- a/lib/Controller/UserController.php +++ b/lib/Controller/UserController.php @@ -71,46 +71,57 @@ class UserController extends ApiController { $response->setStatus(401); return $response; } - $startTime = time(); + $startTimestamp = time(); if (!$this->userService->userExists($uid)) { $response->setStatus(404); return $response; } - $existsTime = time() - $startTime; + $existsTimestamp = time(); + $existsTime = $existsTimestamp - $startTimestamp; + $user = $this->userService->getUser($uid); - if (is_null($user)) { $response->setStatus(404); return $response; } - $getUserTime = time() - $existsTime; + $getUserTimestamp = time(); + $getUserTime = $getUserTimestamp - $existsTimestamp; $user->setEMailAddress($email); - $setEmailTime = time() - $getUserTime; + $setEmailTimestamp = time(); + $setEmailTime = $setEmailTimestamp - $getUserTimestamp; + $user->setQuota($quota); - $setQuotaTime = time() - $setEmailTime; + $setQuotaTimestamp = time(); + $setQuotaTime = $setQuotaTimestamp - $setEmailTimestamp; + $this->config->setUserValue($uid, 'terms_of_service', 'tosAccepted', intval($tosAccepted)); - $setTosTime = time() - $setQuotaTime; + $setTosTimestamp = time(); + $setTosTime = $setTosTimestamp - $setQuotaTimestamp; + $recoveryEmailUpdated = $this->userService->setRecoveryEmail($uid, $recoveryEmail); if (!$recoveryEmailUpdated) { return $this->getErrorResponse($response, 'error_setting_recovery', 400); } - $setRecoveryTime = time() - $setTosTime; + $setRecoveryTimestamp = time(); + $setRecoveryTime = $setRecoveryTimestamp - $setTosTimestamp; + $hmeAliasAdded = $this->userService->addHMEAliasInConfig($uid, $hmeAlias); if (!$hmeAliasAdded) { return $this->getErrorResponse($response, 'error_adding_hme_alias', 400); } - $setHmeTime = time() - $setRecoveryTime; + $setHmeTimestamp = time(); + $setHmeTime = $setHmeTimestamp - $setRecoveryTimestamp; $this->logger->error( - 'setAccountData-benchmark: starting at: ' . $startTime - . ' userExists time: ' . $existsTime - . ' getUser time: ' . $getUserTime - . ' setQuota time: ' . $setQuotaTime - . ' setEmail time: ' . $setEmailTime - . ' setTos time: ' . $setTosTime - . ' setRecovery time: ' . $setRecoveryTime - . ' setHme time: ' . $setHmeTime + 'setAccountData-benchmark: starting at: ' . $startTimestamp . "\n" + . ' userExists time: ' . $existsTime . "\n" + . ' getUser time: ' . $getUserTime . "\n" + . ' setQuota time: ' . $setQuotaTime . "\n" + . ' setEmail time: ' . $setEmailTime . "\n" + . ' setTos time: ' . $setTosTime . "\n" + . ' setRecovery time: ' . $setRecoveryTime . "\n" + . ' setHme time: ' . $setHmeTime . "\n" ); return $response; -- GitLab