From b497067ead79d617a09d081f580b1cd930fcb771 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 23 Sep 2020 12:14:31 +0200 Subject: [PATCH] Log a warning if a "lazy" initial state loads longer than 1 second Signed-off-by: Joas Schilling --- lib/private/InitialStateService.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/private/InitialStateService.php b/lib/private/InitialStateService.php index 55ce9c4172..c74eb683bd 100644 --- a/lib/private/InitialStateService.php +++ b/lib/private/InitialStateService.php @@ -72,7 +72,17 @@ class InitialStateService implements IInitialStateService { private function invokeLazyStateCallbacks(): void { foreach ($this->lazyStates as $app => $lazyStates) { foreach ($lazyStates as $key => $lazyState) { + $startTime = microtime(true); $this->provideInitialState($app, $key, $lazyState()); + $endTime = microtime(true); + $duration = $endTime - $startTime; + if ($duration > 1) { + $this->logger->warning('Lazy initial state provider for {key} took {duration} seconds.', [ + 'app' => $app, + 'key' => $key, + 'duration' => round($duration, 2), + ]); + } } } $this->lazyStates = [];