Skip to content

Commit

Permalink
Merge pull request #4897 from sfadschm/add-filters-timer
Browse files Browse the repository at this point in the history
[4.2][Debug] Add benchmarking for filters.
  • Loading branch information
paulbalandan authored Jul 11, 2021
2 parents 09bc563 + 0680f4f commit b17ec97
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion system/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ protected function handleRequest(?RouteCollectionInterface $routes, Cache $cache
{
$routeFilter = $this->tryToRouteIt($routes);

// Run "before" filters
// Start up the filters
$filters = Services::filters();

// If any filters were specified within the routes file,
Expand All @@ -388,7 +388,10 @@ protected function handleRequest(?RouteCollectionInterface $routes, Cache $cache

// Never run filters when running through Spark cli
if (! defined('SPARKED')) {
// Run "before" filters
$this->benchmark->start('before_filters');
$possibleResponse = $filters->run($uri, 'before');
$this->benchmark->stop('before_filters');

// If a ResponseInterface instance is returned then send it back to the client and stop
if ($possibleResponse instanceof ResponseInterface) {
Expand Down Expand Up @@ -427,8 +430,11 @@ protected function handleRequest(?RouteCollectionInterface $routes, Cache $cache
// Never run filters when running through Spark cli
if (! defined('SPARKED')) {
$filters->setResponse($this->response);

// Run "after" filters
$this->benchmark->start('after_filters');
$response = $filters->run($uri, 'after');
$this->benchmark->stop('after_filters');
} else {
$response = $this->response;

Expand Down

0 comments on commit b17ec97

Please sign in to comment.