3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Request { private $method; private $path; function __construct($method, $path) { $this->method = $method; $this->path = $path; } function getMethod() { return $this->method; } function getPath() { return $this->path; } } class Router { private $routes = [ 'get' => [], 'post' => [] ]; function get($pattern, callable $handler) { $this->routes['get'][$pattern] = $handler; return $this; } function post($pattern, callable $handler) { $this->routes['post'][$pattern] = $handler; return $this; } function match(Request $request) { $method = strtolower($request->getMethod()); if (!isset($this->routes[$method])) { return false; } $path = $request->getPath(); foreach ($this->routes[$method] as $pattern => $handler) { if ($pattern === $path) { return $handler; } } return false; } } class Dispatcher { private $router; function __construct(Router $router) { $this->router = $router; } function handle(Request $request) { $handler = $this->router->match($request); if (!$handler) { echo "Could not find your resource!\n"; return; } $handler(); } } $router = new Router(); $router->get('foo', function() { echo "GET foo\n"; }); $router->post('bar', function() { echo "POST bar\n"; }); $dispatcher = new Dispatcher($router); $dispatcher->handle(new Request('GET', 'foo')); $dispatcher->handle(new Request('POST', 'bar')); $dispatcher->handle(new Request('GET', 'qux'));

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.70.0030.01716.50
8.3.60.0140.00318.56
8.3.50.0140.00522.01
8.3.40.0040.01219.38
8.3.30.0110.00819.21
8.3.20.0090.01024.17
8.3.10.0080.00722.45
8.3.00.0120.00319.66
8.2.190.0120.00318.29
8.2.180.0110.00718.41
8.2.170.0130.00618.91
8.2.160.0160.00221.53
8.2.150.0080.00720.78
8.2.140.0090.00621.92
8.2.130.0100.00522.26
8.2.120.0090.00519.77
8.2.110.0030.01119.96
8.2.100.0070.00718.76
8.2.90.0080.00718.61
8.2.80.0060.00918.87
8.2.70.0130.00328.41
8.2.60.0120.00528.55
8.2.50.0090.00728.55
8.2.40.0120.00328.80
8.2.30.0120.00428.63
8.2.20.0090.00428.50
8.2.10.0110.00428.52
8.2.00.0110.00527.31
8.1.280.0040.01125.92
8.1.270.0110.00422.72
8.1.260.0060.00723.46
8.1.250.0070.00624.17
8.1.240.0060.00819.33
8.1.230.0110.00718.77
8.1.220.0060.00818.61
8.1.210.0070.00618.61
8.1.200.0130.00428.36
8.1.190.0100.00728.32
8.1.180.0110.00828.38
8.1.170.0090.00728.84
8.1.160.0130.00429.29
8.1.150.0100.00728.52
8.1.140.0110.00528.34
8.1.130.0100.00526.97
8.1.120.0090.00826.95
8.1.110.0060.00724.85
8.1.100.0090.00627.32
8.1.90.0090.00726.97
8.1.80.0100.00527.29
8.1.70.0070.00926.97
8.1.60.0100.00625.81
8.1.50.0110.00525.82
8.1.40.0080.00724.93
8.1.30.0110.00524.96
8.1.20.0080.00623.84
8.1.10.0100.00624.94
8.1.00.0120.00424.86
8.0.300.0100.00718.16
8.0.290.0130.00627.88
8.0.280.0130.00628.21
8.0.270.0110.00427.92
8.0.260.0130.00526.74
8.0.250.0120.00626.56
8.0.240.0130.00526.57
8.0.230.0110.00726.54
8.0.220.0110.00526.53
8.0.210.0120.00526.54
8.0.200.0120.00526.56
8.0.190.0130.00525.31
8.0.180.0100.00625.34
8.0.170.0110.00524.37
8.0.160.0110.00324.35
8.0.150.0090.00724.37
8.0.140.0110.00624.33
8.0.130.0110.00623.29
8.0.120.0120.00523.62
8.0.110.0120.00423.65
8.0.100.0130.00323.61
8.0.90.0120.00523.62
8.0.80.0140.00523.75
8.0.70.0110.00423.62
8.0.60.0120.00723.64
8.0.50.0130.00423.64
8.0.30.0100.00820.50
8.0.20.0110.00920.42
8.0.10.0120.00820.57
8.0.00.0100.00920.44
7.4.330.0120.00325.31
7.4.320.0160.00426.27
7.4.300.0140.00726.27
7.4.290.0140.00725.04
7.4.280.0130.00624.10
7.4.270.0130.00524.09
7.4.260.0120.00623.36
7.4.250.0130.00623.32
7.4.240.0140.00522.75
7.4.230.0190.00223.36
7.4.220.0150.00623.35
7.4.210.0140.00723.37
7.4.200.0140.00623.35
7.4.190.0170.00524.13
7.4.180.0170.00524.18
7.4.160.0130.00720.59
7.4.150.0140.00720.19
7.4.140.0140.00719.86
7.4.130.0130.00819.73
7.4.120.0140.00719.60
7.4.110.0150.00719.59
7.4.100.0120.00819.58
7.4.90.0110.00819.44
7.4.80.0110.00819.43
7.4.70.0130.00819.33
7.4.60.0140.00719.33
7.4.50.0120.00819.31
7.4.40.0120.00718.96
7.4.30.0100.00918.95
7.4.20.0120.00718.72
7.4.10.0120.00818.62
7.4.00.0100.00818.44
7.3.330.0140.00422.85
7.3.320.0140.00522.89
7.3.310.0130.00523.22
7.3.300.0130.00523.33
7.3.290.0130.00622.09
7.3.280.0140.00621.62
7.3.270.0120.00720.00
7.3.260.0130.00719.79
7.3.250.0140.00619.60
7.3.240.0130.00719.75
7.3.230.0120.00719.50
7.3.220.0130.00619.61
7.3.210.0140.00719.31
7.3.200.0140.00619.29
7.3.190.0120.00919.19
7.3.180.0140.00719.23
7.3.170.0130.00719.25
7.3.160.0120.00718.87
7.3.150.0130.00718.87
7.3.140.0120.00818.81
7.3.130.0120.00818.53
7.3.120.0120.00718.31
7.3.110.0110.00818.42
7.3.100.0110.00818.24
7.3.90.0110.00818.28
7.3.80.0120.00818.18
7.3.70.0100.00818.14
7.3.60.0110.00718.14
7.3.50.0120.00618.04
7.3.40.0110.00817.87
7.3.30.0100.00817.84
7.3.20.0210.00718.08
7.3.10.0270.00717.72
7.3.00.0360.00717.60
7.2.340.0160.00919.71
7.2.330.0180.00719.48
7.2.320.0160.00919.50
7.2.310.0160.00819.39
7.2.300.0170.00719.35
7.2.290.0150.00719.02
7.2.280.0140.00819.02
7.2.270.0150.00818.95
7.2.260.0150.00818.68
7.2.250.0140.00918.58
7.2.240.0140.00818.60
7.2.230.0140.00818.46
7.2.220.0130.00818.36
7.2.210.0140.00918.37
7.2.200.0140.00718.33
7.2.190.0140.00718.31
7.2.180.0130.00918.18
7.2.170.0140.00818.14
7.2.160.0130.00818.14
7.2.150.0230.00818.37
7.2.140.0230.00918.31
7.2.130.0350.00817.88
7.2.120.0320.00817.82
7.2.110.0350.00817.83
7.2.100.0340.00817.82
7.2.90.0410.00817.74
7.2.80.0290.00917.72
7.2.70.0340.00817.71
7.2.60.0310.00817.72
7.2.50.0330.00817.71
7.2.40.0320.00917.78
7.2.30.0310.00917.72
7.2.20.0310.00817.75
7.2.10.0300.00717.78
7.2.00.0270.00917.78
7.1.330.0190.00718.08
7.1.320.0160.00717.82
7.1.310.0160.00817.78
7.1.300.0160.00817.67
7.1.290.0170.00817.67
7.1.280.0180.00717.55
7.1.270.0180.00817.54
7.1.260.0190.00717.47
7.1.250.0290.00816.78
7.1.240.0330.00816.78
7.1.230.0390.00916.77
7.1.220.0360.00916.74
7.1.210.0380.00716.68
7.1.200.0320.00816.67
7.1.190.0320.00816.71
7.1.180.0390.00716.70
7.1.170.0360.00816.68
7.1.160.0360.00716.75
7.1.150.0340.00816.75
7.1.140.0300.00716.73
7.1.130.0360.00916.73
7.1.120.0310.00716.71
7.1.110.0320.00716.72
7.1.100.0330.00816.68
7.1.90.0310.00816.68
7.1.80.0280.00716.67
7.1.70.0270.00816.64
7.1.60.0300.00817.83
7.1.50.0340.00817.81
7.1.40.0270.00817.75
7.1.30.0290.00717.81
7.1.20.0270.00817.79
7.1.10.0310.00816.69
7.1.00.0250.00716.70
7.0.330.0330.00816.50
7.0.320.0320.00816.52
7.0.310.0340.00816.43
7.0.300.0380.00716.43
7.0.290.0350.00716.35
7.0.280.0320.00816.46
7.0.270.0360.00716.42
7.0.260.0310.00616.35
7.0.250.0280.00816.41
7.0.240.0320.00716.43
7.0.230.0370.00716.41
7.0.220.0270.00816.39
7.0.210.0270.00916.42
7.0.200.0270.00816.41
7.0.190.0230.00716.39
7.0.180.0290.00716.43
7.0.170.0290.00816.45
7.0.160.0270.00816.39
7.0.150.0280.00716.39
7.0.140.0260.00716.42
7.0.130.0270.00816.42
7.0.120.0260.00816.43
7.0.110.0290.00816.43
7.0.100.0310.00716.36
7.0.90.0230.00816.34
7.0.80.0250.00816.37
7.0.70.0320.00616.37
7.0.60.0290.00716.37
7.0.50.0270.00816.40
7.0.40.0300.00716.40
7.0.30.0240.00816.40
7.0.20.0270.00816.33
7.0.10.0240.00816.37
7.0.00.0240.00816.36
5.6.400.0130.01017.62
5.6.390.0130.01017.63
5.6.380.0150.00916.93
5.6.370.0150.00916.97
5.6.360.0140.00916.98
5.6.350.0160.00916.92
5.6.340.0150.00916.89
5.6.330.0150.00816.92
5.6.320.0140.01016.94
5.6.310.0150.00916.97
5.6.300.0150.00916.76
5.6.290.0140.01016.82
5.6.280.0140.01016.80
5.6.270.0140.00916.81
5.6.260.0150.00916.78
5.6.250.0150.00916.78
5.6.240.0140.00916.79
5.6.230.0140.01116.79
5.6.220.0140.00916.80
5.6.210.0150.00916.81
5.6.200.0150.00916.79
5.6.190.0150.00916.81
5.6.180.0150.01016.77
5.6.170.0150.00816.81
5.6.160.0150.00916.79
5.6.150.0140.00916.81
5.6.140.0140.01016.80
5.6.130.0160.00816.83
5.6.120.0140.00916.80
5.6.110.0140.00916.76
5.6.100.0140.00916.75
5.6.90.0140.01016.74
5.6.80.0140.00916.72
5.6.70.0140.00916.74
5.6.60.0140.00916.75
5.6.50.0150.00816.73
5.6.40.0140.00916.73
5.6.30.0150.00916.75
5.6.20.0140.00916.73
5.6.10.0150.00816.71
5.6.00.0140.00816.70
5.5.380.0140.00915.97
5.5.370.0150.00916.04
5.5.360.0130.01015.97
5.5.350.0150.00815.93
5.5.340.0140.00915.97
5.5.330.0140.00815.97
5.5.320.0150.00815.92
5.5.310.0140.00915.98
5.5.300.0150.00916.00
5.5.290.0140.00815.98
5.5.280.0140.00815.94
5.5.270.0140.00815.92
5.5.260.0140.00815.95
5.5.250.0140.00815.93
5.5.240.0140.00815.93
5.5.230.0140.00915.92
5.5.220.0130.00815.89
5.5.210.0120.00915.93
5.5.200.0140.00715.86
5.5.190.0150.00715.87
5.5.180.0130.00915.89
5.5.170.0140.00816.14
5.5.160.0140.00815.90
5.5.150.0140.00815.85
5.5.140.0130.00915.85
5.5.130.0140.00815.83
5.5.120.0140.00815.88
5.5.110.0140.00815.86
5.5.100.0130.00815.91
5.5.90.0140.00815.89
5.5.80.0130.00815.91
5.5.70.0130.00815.91
5.5.60.0130.00815.88
5.5.50.0130.00915.88
5.5.40.0130.00915.89
5.5.30.0130.00815.89
5.5.20.0150.00815.90
5.5.10.0140.00715.84
5.5.00.0140.00815.88
5.4.450.0120.00714.04
5.4.440.0120.00614.08
5.4.430.0110.00714.06
5.4.420.0120.00614.07
5.4.410.0110.00614.06
5.4.400.0120.00714.03
5.4.390.0110.00714.02
5.4.380.0120.00613.99
5.4.370.0120.00614.03
5.4.360.0110.00714.01
5.4.350.0110.00714.01
5.4.340.0120.00614.03
5.4.330.0110.00614.10
5.4.320.0120.00714.04
5.4.310.0140.00614.03
5.4.300.0120.00714.04
5.4.290.0120.00614.03
5.4.280.0120.00614.02
5.4.270.0120.00714.01
5.4.260.0130.00614.01
5.4.250.0120.00614.00
5.4.240.0120.00714.02
5.4.230.0120.00613.99
5.4.220.0110.00713.97
5.4.210.0110.00713.99
5.4.200.0120.00613.99
5.4.190.0130.00613.97
5.4.180.0130.00613.99
5.4.170.0130.00613.98
5.4.160.0120.00614.01
5.4.150.0120.00714.01
5.4.140.0120.00614.07
5.4.130.0110.00714.07
5.4.120.0110.00714.07
5.4.110.0120.00614.05
5.4.100.0110.00714.07
5.4.90.0110.00714.03
5.4.80.0110.00614.08
5.4.70.0110.00614.06
5.4.60.0110.00614.07
5.4.50.0100.00614.05
5.4.40.0120.00514.09
5.4.30.0110.00614.03
5.4.20.0120.00514.04
5.4.10.0110.00614.06
5.4.00.0120.00613.99
5.3.290.0110.00713.81
5.3.280.0110.00713.73
5.3.270.0120.00613.77
5.3.260.0100.00713.78
5.3.250.0120.00613.76
5.3.240.0100.00713.69
5.3.230.0110.00713.74
5.3.220.0120.00613.70
5.3.210.0110.00713.71
5.3.200.0110.00713.72
5.3.190.0120.00613.77
5.3.180.0110.00713.86
5.3.170.0120.00613.86
5.3.160.0110.00613.86
5.3.150.0110.00613.87
5.3.140.0110.00613.81
5.3.130.0110.00713.83
5.3.120.0110.00613.81
5.3.110.0110.00713.78
5.3.100.0120.00613.82
5.3.90.0110.00613.86
5.3.80.0110.00713.75
5.3.70.0110.00713.78
5.3.60.0090.00713.80
5.3.50.0100.00713.75
5.3.40.0110.00713.75
5.3.30.0110.00713.74
5.3.20.0110.00613.75
5.3.10.0110.00613.62
5.3.00.0110.00613.58

preferences:
63.26 ms | 401 KiB | 5 Q