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"; }); $a=new Request('GET', 'foo');

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.0100.01016.63
8.3.50.0090.00617.96
8.3.40.0100.01018.84
8.3.30.0150.00018.98
8.3.20.0060.00320.06
8.3.10.0040.00421.84
8.3.00.0030.00519.25
8.2.180.0070.01416.75
8.2.170.0090.00622.96
8.2.160.0100.00320.39
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0070.00726.16
8.2.120.0080.00019.77
8.2.110.0030.00721.00
8.2.100.0070.00417.75
8.2.90.0050.00319.17
8.2.80.0040.00417.97
8.2.70.0060.00317.74
8.2.60.0000.00818.05
8.2.50.0000.00818.07
8.2.40.0040.00420.07
8.2.30.0040.00418.13
8.2.20.0050.00317.70
8.2.10.0050.00218.21
8.2.00.0030.00517.72
8.1.280.0180.00325.92
8.1.270.0090.00020.64
8.1.260.0070.00026.35
8.1.250.0050.00228.09
8.1.240.0060.00323.82
8.1.230.0120.00017.48
8.1.220.0040.00417.78
8.1.210.0040.00418.77
8.1.200.0060.00317.35
8.1.190.0000.00817.22
8.1.180.0030.00518.10
8.1.170.0000.00820.39
8.1.160.0040.00421.97
8.1.150.0040.00418.86
8.1.140.0040.00417.50
8.1.130.0030.00317.87
8.1.120.0000.00717.44
8.1.110.0000.00717.45
8.1.100.0000.00717.40
8.1.90.0000.00817.36
8.1.80.0000.00717.43
8.1.70.0000.00717.54
8.1.60.0080.00017.52
8.1.50.0000.00817.60
8.1.40.0000.00817.54
8.1.30.0040.00417.53
8.1.20.0050.00317.73
8.1.10.0040.00417.45
8.1.00.0000.00917.54
8.0.300.0050.00318.77
8.0.290.0000.00916.88
8.0.280.0000.00718.35
8.0.270.0030.00317.24
8.0.260.0070.00017.18
8.0.250.0000.00716.89
8.0.240.0070.00016.89
8.0.230.0040.00416.89
8.0.220.0000.00716.98
8.0.210.0070.00016.93
8.0.200.0060.00016.98
8.0.190.0040.00416.97
8.0.180.0070.00017.05
8.0.170.0050.00217.05
8.0.160.0000.00916.99
8.0.150.0000.00717.02
8.0.140.0070.00016.98
8.0.130.0000.00713.43
8.0.120.0000.00817.01
8.0.110.0070.00016.97
8.0.100.0000.00717.05
8.0.90.0080.00016.81
8.0.80.0080.01516.96
8.0.70.0000.00716.89
8.0.60.0040.00417.05
8.0.50.0040.00416.91
8.0.30.0080.02017.01
8.0.20.0220.01417.40
8.0.10.0040.00417.03
8.0.00.0110.01216.92
7.4.330.0050.00015.03
7.4.320.0000.00816.55
7.4.300.0030.00316.56
7.4.290.0030.00316.46
7.4.280.0000.00716.55
7.4.270.0000.00716.54
7.4.260.0030.00416.68
7.4.250.0030.00316.47
7.4.240.0030.00516.51
7.4.230.0030.00316.74
7.4.220.0100.00916.62
7.4.210.0090.00916.71
7.4.200.0030.00516.56
7.4.160.0120.00316.59
7.4.150.0070.01317.40
7.4.140.0110.00717.86
7.4.130.0090.00816.59
7.4.120.0110.00816.51
7.4.110.0100.00716.55
7.4.100.0060.01116.53
7.4.90.0070.01016.75
7.4.80.0110.01119.39
7.4.70.0090.00816.70
7.4.60.0110.00716.54
7.4.50.0050.00316.70
7.4.40.0070.01016.50
7.4.30.0090.00916.56
7.4.00.0080.00814.82
7.3.330.0000.00713.17
7.3.320.0080.00813.36
7.3.310.0030.00316.40
7.3.300.0030.00316.20
7.3.290.0080.00916.39
7.3.280.0070.01316.35
7.3.270.0100.00717.40
7.3.260.0120.00616.43
7.3.250.0120.01016.56
7.3.240.0140.00316.44
7.3.230.0120.00516.39
7.3.210.0090.01116.34
7.3.200.0100.01619.39
7.3.190.0030.01316.67
7.3.180.0110.00416.45
7.3.170.0090.00916.36
7.3.160.0120.00416.48
7.3.120.0120.00314.76
7.3.110.0000.01714.95
7.3.100.0060.01214.88
7.3.90.0030.01414.56
7.3.80.0070.01114.75
7.3.70.0060.00914.97
7.3.60.0080.00814.71
7.3.50.0030.01214.81
7.3.40.0100.00614.72
7.3.30.0080.00614.74
7.3.20.0060.00916.48
7.3.10.0100.00016.55
7.3.00.0030.01016.88
7.2.330.0030.01616.84
7.2.320.0110.00616.64
7.2.310.0150.00616.65
7.2.300.0090.01316.51
7.2.290.0070.01416.77
7.2.250.0030.01615.14
7.2.240.0060.01314.66
7.2.230.0040.01514.90
7.2.220.0000.01114.91
7.2.210.0070.01114.74
7.2.200.0040.00715.03
7.2.190.0070.00714.80
7.2.180.0070.01114.63
7.2.170.0040.00815.14
7.2.00.0030.01419.29
7.1.330.0060.00915.96
7.1.320.0060.00615.63
7.1.310.0160.00015.80
7.1.300.0070.01115.65
7.1.290.0060.01015.84
7.1.280.0040.00815.74
7.1.270.0100.00015.57
7.1.260.0130.00015.50
7.1.100.0140.00417.80
7.1.70.0030.00717.18
7.1.60.0100.01319.50
7.1.50.0040.01916.99
7.1.00.0030.07322.51
7.0.200.0810.00414.67
7.0.140.0030.07322.08
7.0.60.0070.03720.05
7.0.50.0030.04317.89
7.0.40.0030.09319.96
7.0.30.0230.03720.12
7.0.20.0270.07020.09
7.0.10.0270.06020.32
7.0.00.0030.08320.09
5.6.280.0030.07320.88
5.6.210.0170.05320.51
5.6.200.0100.05318.20
5.6.190.0030.05320.60
5.6.180.0200.06020.42
5.6.170.0230.04020.55
5.6.160.0070.05320.54
5.6.150.0000.05318.29
5.6.140.0000.06718.14
5.6.130.0070.06318.16
5.6.120.0100.07321.03
5.6.110.0030.07721.16
5.6.100.0170.03721.00
5.6.90.0370.06720.92
5.6.80.0100.05020.39
5.6.70.0100.03720.54
5.5.350.0170.08020.35
5.5.340.0200.04018.07
5.5.330.0100.03720.21
5.5.320.0270.06320.28
5.5.310.0330.07320.27
5.5.300.0070.04717.95
5.5.290.0200.06717.98
5.5.280.0030.08720.79
5.5.270.0100.08720.66
5.5.260.0070.05020.75
5.5.250.0130.07720.70
5.5.240.0100.05720.39
5.4.450.0630.06019.53
5.4.440.1230.05319.47
5.4.430.0870.07019.43
5.4.420.0600.07719.43
5.4.410.0930.05719.22
5.4.400.1070.06318.52
5.4.390.0930.06718.81
5.4.380.1000.06018.71
5.4.370.1200.04318.60
5.4.360.1130.05718.57
5.4.350.1030.04718.77
5.4.340.0970.06018.76
5.4.320.1170.04318.52
5.4.310.1300.05018.48
5.4.300.1000.06018.47
5.4.290.0970.06018.75
5.4.280.1000.05718.79
5.4.270.0870.06018.62
5.4.260.1070.05018.56
5.4.250.1000.04718.76
5.4.240.1130.05018.75
5.4.230.1130.04318.76
5.4.220.1030.05718.57
5.4.210.1030.05318.70
5.4.200.1300.06316.67
5.4.190.1000.05718.82
5.4.180.1030.05718.79
5.4.170.1030.05318.50
5.4.160.1030.05318.61
5.4.150.1070.04718.77
5.4.140.1030.05316.23
5.4.130.1130.04316.36
5.4.120.0870.06316.37
5.4.110.1070.05016.22
5.4.100.0930.06016.22
5.4.90.1000.05016.22
5.4.80.0870.05716.35
5.4.70.1000.04316.32
5.4.60.1070.04316.27
5.4.50.1000.05316.29
5.4.40.1070.05316.32
5.4.30.1030.05016.40
5.4.20.1100.04316.30
5.4.10.1000.05016.30
5.4.00.1000.05015.74
5.3.290.0970.05014.71
5.3.280.1000.06014.61
5.3.270.0870.05714.66
5.3.260.1070.05014.67
5.3.250.1330.05014.64
5.3.240.1070.05314.72
5.3.230.1070.05014.73
5.3.220.0900.05314.80
5.3.210.0930.05014.63
5.3.200.1230.07314.62
5.3.190.1070.05014.79
5.3.180.0830.05714.70
5.3.170.0900.05314.67
5.3.160.0970.05314.70
5.3.150.1000.05014.61
5.3.140.1100.05014.62
5.3.130.1070.04714.79
5.3.120.0900.05714.55
5.3.110.0930.05314.77
5.3.100.0930.05014.23
5.3.90.0970.04314.04
5.3.80.0970.04714.14
5.3.70.0870.05314.05
5.3.60.0930.04314.08
5.3.50.0900.05013.98
5.3.40.1000.05314.16
5.3.30.1030.05013.91
5.3.20.1170.04313.79
5.3.10.0830.05313.83
5.3.00.0970.05313.70
5.2.170.0800.04711.36
5.2.160.0800.04711.27
5.2.150.0870.04311.26
5.2.140.0700.04311.35
5.2.130.0830.05011.31
5.2.120.0700.04011.21
5.2.110.0770.04711.14
5.2.100.0800.04311.17
5.2.90.0830.04311.11
5.2.80.0830.04311.14
5.2.70.0930.04311.18
5.2.60.0930.04711.16
5.2.50.0730.04011.05
5.2.40.0570.04011.03
5.2.30.0630.05010.95
5.2.20.1030.04011.02
5.2.10.0730.03710.91
5.2.00.0700.03710.75
5.1.60.0670.03310.03
5.1.50.0630.03710.00
5.1.40.0630.03710.02
5.1.30.0570.03710.45
5.1.20.0600.03310.54
5.1.10.0570.03710.07
5.1.00.0570.03710.07
5.0.50.0430.0238.76
5.0.40.0270.0308.46
5.0.30.0270.0438.30
5.0.20.0300.0338.39
5.0.10.0330.0238.21
5.0.00.0300.0538.30
4.4.90.0370.0305.90
4.4.80.0330.0175.86
4.4.70.0330.0235.98
4.4.60.0330.0275.95
4.4.50.0300.0305.92
4.4.40.0300.0335.88
4.4.30.0400.0135.87
4.4.20.0330.0205.96
4.4.10.0370.0236.05
4.4.00.0370.0405.95
4.3.110.0270.0305.92
4.3.100.0370.0175.85
4.3.90.0330.0235.91
4.3.80.0330.0335.82
4.3.70.0370.0175.82
4.3.60.0330.0235.91
4.3.50.0330.0235.77
4.3.40.0300.0375.76
4.3.30.0130.0275.05
4.3.20.0200.0205.05
4.3.10.0170.0205.05
4.3.00.0130.0207.00

preferences:
39.91 ms | 400 KiB | 5 Q