diff --git a/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php
index 6fd0b99..8f91a0e 100644
--- a/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php
@@ -77,6 +77,7 @@ public function __construct(AuthenticationProviderInterface $authentication_prov
* @see \Drupal\Core\Authentication\AuthenticationProviderInterface::authenticate()
*/
public function onKernelRequestAuthenticate(GetResponseEvent $event) {
+ $GLOBALS['_time']['pre_authenticate'] = microtime(TRUE);
if ($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST) {
$request = $event->getRequest();
if ($this->authenticationProvider->applies($request)) {
@@ -86,6 +87,7 @@ public function onKernelRequestAuthenticate(GetResponseEvent $event) {
}
}
}
+ $GLOBALS['_time']['post_authenticate'] = microtime(TRUE);
}
/**
diff --git a/core/lib/Drupal/Core/StackMiddleware/Session.php b/core/lib/Drupal/Core/StackMiddleware/Session.php
index e0ed0e4..aa77da8 100644
--- a/core/lib/Drupal/Core/StackMiddleware/Session.php
+++ b/core/lib/Drupal/Core/StackMiddleware/Session.php
@@ -53,6 +53,7 @@ public function __construct(HttpKernelInterface $http_kernel, $service_name = 's
* {@inheritdoc}
*/
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
+ $GLOBALS['_time']['pre_session'] = microtime(TRUE);
if ($type === self::MASTER_REQUEST && PHP_SAPI !== 'cli') {
$session = $this->container->get($this->sessionServiceName);
$session->start();
diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/RouterListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/RouterListener.php
index db05fca..00d340c 100644
--- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/RouterListener.php
+++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/RouterListener.php
@@ -120,6 +120,7 @@ public function onKernelRequest(GetResponseEvent $event)
// add attributes based on the request (routing)
try {
+ $GLOBALS['_time']['pre_routing'] = microtime(TRUE);
// matching a request is more powerful than matching a URL path + context, so try that first
if ($this->matcher instanceof RequestMatcherInterface) {
$parameters = $this->matcher->matchRequest($request);
@@ -134,6 +135,7 @@ public function onKernelRequest(GetResponseEvent $event)
$request->attributes->add($parameters);
unset($parameters['_route'], $parameters['_controller']);
$request->attributes->set('_route_params', $parameters);
+ $GLOBALS['_time']['post_routing'] = microtime(TRUE);
} catch (ResourceNotFoundException $e) {
$message = sprintf('No route found for "%s %s"', $request->getMethod(), $request->getPathInfo());
diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php
index c69b75a..92d8912 100644
--- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php
+++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php
@@ -121,6 +121,8 @@ private function handleRaw(Request $request, $type = self::MASTER_REQUEST)
{
$this->requestStack->push($request);
+ $GLOBALS['_time']['pre_request_event'] = microtime(TRUE);
+
// request
$event = new GetResponseEvent($this, $request, $type);
$this->dispatcher->dispatch(KernelEvents::REQUEST, $event);
@@ -129,6 +131,8 @@ private function handleRaw(Request $request, $type = self::MASTER_REQUEST)
return $this->filterResponse($event->getResponse(), $request, $type);
}
+ $GLOBALS['_time']['pre_controller'] = microtime(TRUE);
+
// load controller
if (false === $controller = $this->resolver->getController($request)) {
throw new NotFoundHttpException(sprintf('Unable to find the controller for path "%s". The route is wrongly configured.', $request->getPathInfo()));
@@ -144,6 +148,8 @@ private function handleRaw(Request $request, $type = self::MASTER_REQUEST)
// call controller
$response = call_user_func_array($controller, $arguments);
+ $GLOBALS['_time']['pre_view_event'] = microtime(TRUE);
+
// view
if (!$response instanceof Response) {
$event = new GetResponseForControllerResultEvent($this, $request, $type, $response);
diff --git a/index.php b/index.php
index 53392f9..b5d66ea 100644
--- a/index.php
+++ b/index.php
@@ -14,6 +14,8 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
+$GLOBALS['_time']['start'] = microtime(TRUE);
+
$autoloader = require_once 'autoload.php';
try {
@@ -42,3 +44,16 @@
print $message;
throw $e;
}
+
+$GLOBALS['_time']['done'] = microtime(TRUE);
+
+print "Start to pre session: " . ($GLOBALS['_time']['pre_session'] - $GLOBALS['_time']['start'])*1000 . 'ms
';
+print "Pre session to pre request event: " . ($GLOBALS['_time']['pre_request_event'] - $GLOBALS['_time']['pre_session'])*1000 . 'ms
';
+print "Pre request event to pre authentication: " . ($GLOBALS['_time']['pre_authenticate'] - $GLOBALS['_time']['pre_request_event'])*1000 . 'ms
';
+print "Authentication: " . ($GLOBALS['_time']['post_authenticate'] - $GLOBALS['_time']['pre_authenticate'])*1000 . 'ms
';
+print "Post authentication to pre routing: " . ($GLOBALS['_time']['pre_routing'] - $GLOBALS['_time']['post_authenticate'])*1000 . 'ms
';
+print "Routing: " . ($GLOBALS['_time']['post_routing'] - $GLOBALS['_time']['pre_routing'])*1000 . 'ms
';
+print "Post routing to pre controller: " . ($GLOBALS['_time']['pre_controller'] - $GLOBALS['_time']['post_routing'])*1000 . 'ms
';
+print "Pre controller to pre view event: " . ($GLOBALS['_time']['pre_view_event'] - $GLOBALS['_time']['pre_controller'])*1000 . 'ms
';
+print "Pre view event to done: " . ($GLOBALS['_time']['done'] - $GLOBALS['_time']['pre_view_event'])*1000 . 'ms
';
+