3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\Controller; use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; /** * ExceptionController. * * @author Fabien Potencier <fabien@symfony.com> */ class ExceptionController { protected $twig; protected $debug; public function __construct(\Twig_Environment $twig, $debug) { $this->twig = $twig; $this->debug = $debug; } /** * Converts an Exception to a Response. * * @param Request $request The request * @param FlattenException $exception A FlattenException instance * @param DebugLoggerInterface $logger A DebugLoggerInterface instance * @param string $_format The format to use for rendering (html, xml, ...) * * @return Response * * @throws \InvalidArgumentException When the exception template does not exist */ public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null, $_format = 'html') { $currentContent = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1)); $code = $exception->getStatusCode(); return new Response($this->twig->render( $this->findTemplate($request, $_format, $code, $this->debug), array( 'status_code' => $code, 'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '', 'exception' => $exception, 'logger' => $logger, 'currentContent' => $currentContent, ) )); } /** * @param integer $startObLevel * * @return string */ protected function getAndCleanOutputBuffering($startObLevel) { // ob_get_level() never returns 0 on some Windows configurations, so if // the level is the same two times in a row, the loop should be stopped. $previousObLevel = null; $currentContent = ''; while (($obLevel = ob_get_level()) > $startObLevel && $obLevel !== $previousObLevel) { $previousObLevel = $obLevel; $currentContent .= ob_get_clean(); } return $currentContent; } /** * @param Request $request * @param string $format * @param integer $code An HTTP response status code * @param Boolean $debug * * @return TemplateReference */ protected function findTemplate(Request $request, $format, $code, $debug) { $name = $debug ? 'exception' : 'error'; if ($debug && 'html' == $format) { $name = 'exception_full'; } // when not in debug, try to find a template for the specific HTTP status code and format if (!$debug) { $template = new TemplateReference('TwigBundle', 'Exception', $name.$code, $format, 'twig'); if ($this->templateExists($template)) { return $template; } } // try to find a template for the given format $template = new TemplateReference('TwigBundle', 'Exception', $name, $format, 'twig'); if ($this->templateExists($template)) { return $template; } // default to a generic HTML exception $request->setRequestFormat('html'); return new TemplateReference('TwigBundle', 'Exception', $name, 'html', 'twig'); } // to be removed when the minimum required version of Twig is >= 2.0 protected function templateExists($template) { $loader = $this->twig->getLoader(); if ($loader instanceof \Twig_ExistsLoaderInterface) { return $loader->exists($template); } try { $loader->getSource($template); return true; } catch (\Twig_Error_Loader $e) { } return false; } } class ExceptionController2 extends ExceptionController { /** * Converts an Exception to a Response. * * @param Request $request The request * @param FlattenException $exception A FlattenException instance * @param DebugLoggerInterface $logger A DebugLoggerInterface instance * @param string $_format The format to use for rendering (html, xml, ...) * * @return Response * * @throws \InvalidArgumentException When the exception template does not exist */ public function showAction(Request $request, Symfony\Component\HttpKernel\Exception\FlattenException $exception, DebugLoggerInterface $logger = null, $_format = 'html') { $currentContent = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1)); $code = $exception->getStatusCode(); return new Response($this->twig->render( $this->findTemplate($request, $_format, $code, $this->debug), array( 'status_code' => $code, 'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '', 'exception' => $exception, 'logger' => $logger, 'currentContent' => $currentContent, ) )); } }

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0130.00318.60
8.3.50.0100.01021.84
8.3.40.0090.00918.71
8.3.30.0140.00018.92
8.3.20.0040.00420.25
8.3.10.0050.00323.66
8.3.00.0040.00422.35
8.2.180.0160.00316.50
8.2.170.0110.00422.96
8.2.160.0060.00820.38
8.2.150.0030.00524.18
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0040.00422.27
8.2.110.0140.00722.12
8.2.100.0070.00417.66
8.2.90.0040.00419.09
8.2.80.0000.00817.97
8.2.70.0070.00317.36
8.2.60.0040.00418.04
8.2.50.0030.00518.07
8.2.40.0040.00419.28
8.2.30.0030.00518.02
8.2.20.0040.00417.50
8.2.10.0000.00819.39
8.2.00.0050.00317.54
8.1.280.0110.00425.92
8.1.270.0050.00322.02
8.1.260.0060.00326.35
8.1.250.0070.00028.09
8.1.240.0060.00324.00
8.1.230.0060.00619.15
8.1.220.0040.00417.74
8.1.210.0030.00618.77
8.1.200.0070.00417.23
8.1.190.0050.00317.38
8.1.180.0030.00618.10
8.1.170.0000.00918.56
8.1.160.0000.00821.92
8.1.150.0040.00418.53
8.1.140.0040.00417.34
8.1.130.0030.00317.85
8.1.120.0040.00417.50
8.1.110.0050.00317.39
8.1.100.0030.00317.39
8.1.90.0000.00717.43
8.1.80.0000.00717.46
8.1.70.0030.00517.30
8.1.60.0000.00817.44
8.1.50.0000.00817.46
8.1.40.0080.00017.46
8.1.30.0040.00417.57
8.1.20.0040.00417.69
8.1.10.0000.00817.41
8.1.00.0090.00317.32
8.0.300.0040.00418.77
8.0.290.0040.00417.05
8.0.280.0000.00718.46
8.0.270.0050.00317.14
8.0.260.0000.00616.89
8.0.250.0030.00317.06
8.0.240.0070.00016.94
8.0.230.0000.00716.98
8.0.220.0070.00016.85
8.0.210.0040.00716.93
8.0.200.0070.00016.89
8.0.190.0080.00016.90
8.0.180.0000.00816.84
8.0.170.0000.00916.96
8.0.160.0070.00016.92
8.0.150.0000.00916.86
8.0.140.0080.00016.91
8.0.130.0110.00013.42
8.0.120.0050.00316.91
8.0.110.0080.00016.89
8.0.100.0070.00016.80
8.0.90.0050.00316.73
8.0.80.0060.01316.99
8.0.70.0030.00616.83
8.0.60.0040.00416.95
8.0.50.0040.00417.02
8.0.30.0080.01117.10
8.0.20.0100.00817.40
8.0.10.0000.00716.96
8.0.00.0120.00616.79
7.4.330.0020.00215.00
7.4.320.0000.00716.57
7.4.300.0030.00316.58
7.4.290.0040.00416.55
7.4.280.0030.00316.44
7.4.270.0070.00316.50
7.4.260.0080.00016.47
7.4.250.0040.00416.43
7.4.240.0020.00516.53
7.4.230.0030.00316.64
7.4.220.0120.00616.58
7.4.210.0060.00816.59
7.4.200.0040.00416.48
7.4.190.0070.00016.66
7.4.160.0100.00616.45
7.4.150.0200.00817.40
7.4.140.0110.01017.86
7.4.130.0070.01016.66
7.4.120.0080.00816.65
7.4.110.0060.01316.69
7.4.100.0110.00716.48
7.4.90.0040.01416.47
7.4.80.0060.01219.39
7.4.70.0150.00316.52
7.4.60.0070.01016.49
7.4.50.0000.00816.27
7.4.40.0100.00622.77
7.4.30.0130.00316.55
7.4.00.0060.01014.92
7.3.330.0000.00513.33
7.3.320.0050.00013.18
7.3.310.0070.00016.34
7.3.300.0000.00716.25
7.3.290.0080.00716.30
7.3.280.0120.00616.26
7.3.270.0030.01417.40
7.3.260.0040.01516.20
7.3.250.0090.00916.37
7.3.240.0070.01716.50
7.3.230.0040.01216.39
7.3.210.0090.00916.20
7.3.200.0130.00319.39
7.3.190.0100.01316.21
7.3.180.0030.01416.29
7.3.170.0080.01216.40
7.3.160.0110.01116.47
7.3.120.0000.01314.76
7.2.330.0110.00616.55
7.2.320.0060.01216.45
7.2.310.0060.00916.39
7.2.300.0040.01416.61
7.2.290.0060.01116.39
7.2.110.0170.00316.14
7.2.60.0080.00416.63
7.1.200.0000.00915.35
7.1.70.0030.00616.99
7.1.60.0110.01519.29
7.1.50.0040.01816.86
7.1.00.0000.07722.31
7.0.200.0130.00316.54
7.0.140.0070.07321.91
7.0.100.0100.08020.02
7.0.90.0030.08720.02
7.0.80.0130.07020.10
7.0.70.0300.06320.00
7.0.60.0130.07019.86
7.0.50.0170.05020.32
7.0.40.0100.08020.07
7.0.30.0130.08320.13
7.0.20.0270.06720.10
7.0.10.0170.06320.04
7.0.00.0070.08720.09
5.6.280.0100.07021.05
5.6.250.0070.08320.63
5.6.240.0100.04720.65
5.6.230.0030.05020.60
5.6.220.0030.08720.65
5.6.210.0030.06020.65
5.6.200.0030.06721.07
5.6.190.0100.08021.17
5.6.180.0070.08321.11
5.6.170.0070.05020.97
5.6.160.0130.04321.12
5.6.150.0100.06721.06
5.6.140.0000.05721.16
5.6.130.0170.06720.99
5.6.120.0000.07321.13
5.6.110.0030.05021.13
5.6.100.0030.07021.07
5.6.90.0070.06321.13
5.6.80.0130.07320.45
5.6.70.0070.08020.51
5.6.60.0070.08320.43
5.6.50.0070.08020.50
5.6.40.0100.04720.41
5.6.30.0070.06720.45
5.6.20.0100.08020.35
5.6.10.0030.06720.32
5.6.00.0130.08020.48
5.5.380.0030.04720.43
5.5.370.0070.07020.53
5.5.360.0070.08020.37
5.5.350.0070.05320.45
5.5.340.0030.05020.95
5.5.330.0070.05020.86
5.5.320.0070.08020.81
5.5.310.0070.08320.79
5.5.300.0100.04720.96
5.5.290.0070.04020.91
5.5.280.0170.08720.91
5.5.270.0030.06020.67
5.5.260.0070.06720.85
5.5.250.0100.07020.67
5.5.240.0030.05020.31
5.5.230.0030.08020.19
5.5.220.0170.03020.20
5.5.210.0070.04020.25
5.5.200.0170.05720.12
5.5.190.0070.05020.18
5.5.180.0030.04020.14
5.5.160.0100.07720.24
5.5.150.0070.07720.30
5.5.140.0070.04720.16
5.5.130.0070.05320.21
5.5.120.0030.04020.24
5.5.110.0130.07320.11
5.5.100.0030.06320.11
5.5.90.0100.04020.13
5.5.80.0130.07320.10
5.5.70.0100.07320.10
5.5.60.0130.07320.19
5.5.50.0100.07020.04
5.5.40.0030.08020.11
5.5.30.0130.04720.19
5.5.20.0070.08720.03
5.5.10.0130.07320.05
5.5.00.0070.08020.11
5.4.450.0070.08319.51
5.4.440.0200.06319.37
5.4.430.0100.06719.22
5.4.420.0030.07019.51
5.4.410.0030.06319.10
5.4.400.0170.04319.23
5.4.390.0200.06319.13
5.4.380.0070.04319.13
5.4.370.0000.04718.85
5.4.360.0030.08019.13
5.4.350.0200.05719.05
5.4.340.0070.07318.95
5.4.320.0070.07719.14
5.4.310.0100.06319.04
5.4.300.0130.04718.95
5.4.290.0030.07019.14
5.4.280.0070.03718.87
5.4.270.0070.06019.24
5.4.260.0070.07319.18
5.4.250.0070.07019.00
5.4.240.0130.07019.15
5.4.230.0070.04318.94
5.4.220.0200.07018.87
5.4.210.0070.06319.01
5.4.200.0070.06019.03
5.4.190.0070.07318.84
5.4.180.0200.05318.89
5.4.170.0070.05018.89
5.4.160.0100.04318.91
5.4.150.0100.06019.02
5.4.140.0070.07716.31
5.4.130.0030.06316.49
5.4.120.0070.03316.48
5.4.110.0130.05716.49
5.4.100.0070.07316.56
5.4.90.0130.06316.49
5.4.80.0130.07016.52
5.4.70.0170.03016.39
5.4.60.0030.06016.37
5.4.50.0070.04716.42
5.4.40.0070.07316.45
5.4.30.0100.07016.34
5.4.20.0000.07316.47
5.4.10.0100.04716.43
5.4.00.0130.07315.91
5.3.290.0070.07314.65
5.3.280.0130.03714.61
5.3.270.0100.07314.63
5.3.260.0030.07014.64
5.3.250.0030.03714.63
5.3.240.0030.05314.59
5.3.230.0070.04014.61
5.3.220.0030.04014.67
5.3.210.0100.06014.54
5.3.200.0070.04014.59
5.3.190.0070.05714.53
5.3.180.0130.06714.71
5.3.170.0030.05714.57
5.3.160.0070.07314.52
5.3.150.0000.06014.71
5.3.140.0100.06714.56
5.3.130.0100.03314.70
5.3.120.0200.05014.72
5.3.110.0070.03314.52
5.3.100.0070.05714.11
5.3.90.0000.06314.08
5.3.80.0000.04014.08
5.3.70.0100.02713.94
5.3.60.0100.03014.07
5.3.50.0070.07314.01
5.3.40.0070.04013.88
5.3.30.0070.04714.03
5.3.20.0000.05713.64
5.3.10.0000.05313.72
5.3.00.0070.05713.81

preferences:
36.27 ms | 401 KiB | 5 Q