diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index a0785131fc..2ddac1394d 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -88,10 +88,10 @@ App::post('/v1/projects') ->inject('hooks') ->action(function (string $projectId, string $name, string $teamId, string $region, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, Request $request, Response $response, Database $dbForConsole, Cache $cache, Group $pools, Hooks $hooks) { - $ctime = time(); + $ctime = \microtime(true); var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - Before getDocument('teams')"); $team = $dbForConsole->getDocument('teams', $teamId); - $diff = time() - $ctime; + $diff = \microtime(true) - $ctime; var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - After getDocument('teams') : " . $diff . " sec"); if ($team->isEmpty()) { @@ -159,7 +159,7 @@ App::post('/v1/projects') try { - $ctime = time(); + $ctime = \microtime(true); var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - Before createDocument('projects')"); $project = $dbForConsole->createDocument('projects', new Document([ '$id' => $projectId, @@ -195,7 +195,7 @@ App::post('/v1/projects') 'database' => $dsn, ])); - $diff = time() - $ctime; + $diff = \microtime(true) - $ctime; var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - After createDocument('projects') : " . $diff . " sec"); } catch (Duplicate) { throw new Exception(Exception::PROJECT_ALREADY_EXISTS); @@ -248,10 +248,10 @@ App::post('/v1/projects') }, $collection['indexes']); try { - $ctime = time(); + $ctime = \microtime(true); var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - Before createCollection('".$key."')"); $dbForProject->createCollection($key, $attributes, $indexes); - $diff = time() - $ctime; + $diff = \microtime(true) - $ctime; var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - After createCollection('".$key."') : " . $diff . " sec"); } catch (Duplicate) { // Collection already exists diff --git a/app/controllers/general.php b/app/controllers/general.php index 4e84a88c34..b2d4ad69a1 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -462,7 +462,7 @@ App::init() */ - $ctime = time(); + $ctime = \microtime(true); var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before general first init hook"); $host = $request->getHostname() ?? ''; $mainDomain = System::getEnv('_APP_DOMAIN', ''); @@ -666,7 +666,7 @@ App::init() throw new AppwriteException(AppwriteException::GENERAL_UNKNOWN_ORIGIN, $originValidator->getDescription()); } - $diff = time() - $ctime; + $diff = \microtime(true) - $ctime; var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After general first init hook : " . $diff . " sec"); }); diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index fb06e24e77..f4b38f1eb4 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -162,7 +162,7 @@ App::init() ->inject('mode') ->inject('team') ->action(function (App $utopia, Request $request, Database $dbForConsole, Document $project, Document $user, ?Document $session, array $servers, string $mode, Document $team) { - $ctime = time(); + $ctime = \microtime(true); var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api first init hook"); $route = $utopia->getRoute(); @@ -347,7 +347,7 @@ App::init() throw new Exception(Exception::USER_MORE_FACTORS_REQUIRED); } } - $diff = time() - $ctime; + $diff = \microtime(true) - $ctime; var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api first init hook : " . $diff . " sec"); }); @@ -368,7 +368,7 @@ App::init() ->inject('dbForProject') ->inject('mode') ->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Event $queueForEvents, Messaging $queueForMessaging, Audit $queueForAudits, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, Usage $queueForUsage, Database $dbForProject, string $mode) use ($databaseListener) { - $ctime = time(); + $ctime = \microtime(true); var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api second init hook"); $route = $utopia->getRoute(); @@ -527,7 +527,7 @@ App::init() ; } } - $diff = time() - $ctime; + $diff = \microtime(true) - $ctime; var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api second init hook : " . $diff . " sec"); }); @@ -559,6 +559,7 @@ App::shutdown() ->inject('project') ->inject('dbForProject') ->action(function (App $utopia, Request $request, Response $response, Document $project, Database $dbForProject) { + $ctime = \microtime(true); var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api first shutdown hook"); $route = $utopia->getRoute(); $sessionLimit = $project->getAttribute('auths', [])['maxSessions'] ?? APP_LIMIT_USER_SESSIONS_DEFAULT; @@ -585,7 +586,7 @@ App::shutdown() } $dbForProject->purgeCachedDocument('users', $userId); - $diff = time() - $ctime; + $diff = \microtime(true) - $ctime; var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api first shutdown hook : " . $diff . " sec"); }); @@ -609,7 +610,7 @@ App::shutdown() ->inject('dbForConsole') ->inject('realtimeConnection') ->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Event $queueForEvents, Audit $queueForAudits, Usage $queueForUsage, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, Messaging $queueForMessaging, Database $dbForProject, Func $queueForFunctions, string $mode, Database $dbForConsole, callable $realtimeConnection) use ($parseLabel) { - $ctime = time(); + $ctime = \microtime(true); var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api second shutdown hook"); $route = $utopia->getRoute(); $responsePayload = $response->getPayload(); @@ -814,7 +815,7 @@ App::shutdown() } } } - $diff = time() - $ctime; + $diff = \microtime(true) - $ctime; var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api second shutdown hook : " . $diff . " sec"); });