3v4l.org

run code in 300+ PHP versions simultaneously
<?php header('Content-type: text/plain'); $middleware = ['middle_a', 'middle_b', 'middle_c', 'middle_d', 'middle_e']; function middle_a($output, $next) { echo __FUNCTION__ . ":before\n"; $output = $next($output+1); echo __FUNCTION__ . ":after\n"; return $output; } function middle_b($output, $next) { echo __FUNCTION__ . ":before\n"; $output = $next($output+1); echo __FUNCTION__ . ":after\n"; return $output; } function middle_c($output, $next) { try { echo __FUNCTION__ . ":before\n"; $output = $next($output+1); echo __FUNCTION__ . ":after\n"; return $output; } catch (Exception1 $ex) { echo __FUNCTION__ . ":after\n"; // echo __FUNCTION__ . " caught a `" . get_class($ex) . "` and throws a `Exception2`\n"; // throw new Exception2(-100); return -100; // return $next(-100); } } function middle_d($output, $next) { echo __FUNCTION__ . ":before\n"; $output = $next($output+1); echo __FUNCTION__ . ":after\n"; return $output; } function middle_e($output, $next) { echo __FUNCTION__ . ":before\n"; $output = $next($output+1); echo __FUNCTION__ . ":after\n"; return $output; } class Exception1 extends Exception {} class Exception2 extends Exception {} class Exception3 extends Exception {} function act($input) { echo __FUNCTION__ . ":start\n"; throw new Exception1; return $input; } $pipeline = function($input) { return act($input); }; foreach (array_reverse($middleware) as $cb) { $pipeline = function($input) use ($cb, $pipeline) { return $cb($input, $pipeline); }; } try { var_dump($pipeline(0)); } catch (\Exception $ex) { exit("App caught a `" . get_class($ex) . "`"); }

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.130.0070.00318.48
8.3.120.0090.00918.87
8.3.110.0040.00416.65
8.3.100.0050.00324.06
8.3.90.0040.00426.77
8.3.80.0060.00318.43
8.3.70.0070.01316.38
8.3.60.0110.00416.38
8.3.50.0100.00722.82
8.3.40.0140.00718.98
8.3.30.0100.01018.67
8.3.20.0080.00021.82
8.3.10.0050.00321.91
8.3.00.0030.00519.79
8.2.250.0080.00016.68
8.2.240.0050.00519.15
8.2.230.0040.00820.94
8.2.220.0090.00937.54
8.2.210.0000.00926.77
8.2.200.0060.00318.41
8.2.190.0120.00416.88
8.2.180.0070.00725.92
8.2.170.0150.00322.96
8.2.160.0030.01022.96
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0020.00522.25
8.2.120.0080.00026.35
8.2.110.0030.00720.36
8.2.100.0080.00417.72
8.2.90.0060.00318.34
8.2.80.0050.00320.59
8.2.70.0030.00617.63
8.2.60.0000.00917.50
8.2.50.0080.00017.63
8.2.40.0000.00822.33
8.2.30.0040.00419.32
8.2.20.0000.00817.68
8.2.10.0040.00418.14
8.2.00.0030.00518.02
8.1.300.0110.00718.59
8.1.290.0030.00630.84
8.1.280.0180.00425.92
8.1.270.0040.00423.99
8.1.260.0080.00028.09
8.1.250.0070.00028.09
8.1.240.0060.00323.82
8.1.230.0040.00723.83
8.1.220.0040.00417.79
8.1.210.0060.00318.77
8.1.200.0060.00317.22
8.1.190.0050.00317.36
8.1.180.0060.00318.10
8.1.170.0040.00418.46
8.1.160.0040.00422.20
8.1.150.0050.00222.68
8.1.140.0030.00619.56
8.1.130.0000.00717.79
8.1.120.0000.00717.39
8.1.110.0040.00417.36
8.1.100.0070.00017.34
8.1.90.0030.00517.38
8.1.80.0000.00817.48
8.1.70.0050.00217.48
8.1.60.0030.00617.62
8.1.50.0060.00317.58
8.1.40.0030.00517.50
8.1.30.0040.00417.67
8.1.20.0080.00017.64
8.1.10.0030.00517.56
8.1.00.0000.00817.55
8.0.300.0020.00520.14
8.0.290.0000.00816.75
8.0.280.0040.00418.38
8.0.270.0030.00517.29
8.0.260.0070.00017.28
8.0.250.0030.00317.09
8.0.240.0030.00517.04
8.0.230.0040.00316.93
8.0.220.0030.00517.02
8.0.210.0070.00016.93
8.0.200.0070.00016.99
8.0.190.0040.00416.93
8.0.180.0000.00717.02
8.0.170.0060.00316.90
8.0.160.0000.00817.06
8.0.150.0040.00417.00
8.0.140.0030.00316.82
8.0.130.0030.00313.36
8.0.120.0040.00416.93
8.0.110.0000.00716.97
8.0.100.0040.00417.05
8.0.90.0040.00417.03
8.0.80.0090.01216.93
8.0.70.0040.00416.78
8.0.60.0040.00417.03
8.0.50.0040.00416.90
8.0.30.0100.00717.33
8.0.20.0080.01117.40
8.0.10.0000.00716.90
8.0.00.0080.01016.92
7.4.330.0030.00315.09
7.4.320.0000.00716.46
7.4.300.0000.00616.64
7.4.290.0070.00016.60
7.4.280.0050.00316.44
7.4.270.0070.00016.56
7.4.260.0000.00816.61
7.4.250.0020.00516.50
7.4.240.0030.00316.54
7.4.230.0070.00016.69
7.4.220.0050.00316.66
7.4.210.0070.01416.71
7.4.200.0000.00816.61
7.4.160.0080.00816.62
7.4.150.0150.00917.40
7.4.140.0030.01417.86
7.4.130.0100.00816.62
7.4.120.0120.00516.54
7.4.110.0090.00916.52
7.4.100.0210.00316.62
7.4.90.0140.00416.67
7.4.80.0070.01119.39
7.4.70.0090.01416.68
7.4.60.0060.00916.68
7.4.50.0090.00616.43
7.4.40.0110.00616.49
7.4.30.0060.01216.79
7.4.00.0100.00715.04
7.3.330.0000.00513.44
7.3.320.0060.00013.42
7.3.310.0030.00316.45
7.3.300.0030.00316.33
7.3.290.0090.00616.41
7.3.280.0050.01116.39
7.3.270.0090.00917.40
7.3.260.0110.00616.60
7.3.250.0110.00716.46
7.3.240.0090.01116.70
7.3.230.0030.01516.66
7.3.210.0030.01416.38
7.3.200.0040.01616.66
7.3.190.0090.01216.53
7.3.180.0180.00016.68
7.3.170.0100.01016.67
7.3.160.0070.01016.46
7.3.120.0130.00314.92
7.3.110.0100.00714.72
7.3.100.0040.01115.00
7.3.90.0120.00614.87
7.3.80.0100.00314.83
7.3.70.0060.00614.95
7.3.60.0050.00514.79
7.3.50.0060.00915.00
7.3.40.0030.01014.72
7.3.30.0000.01014.83
7.3.20.0040.00716.58
7.3.10.0000.01116.76
7.3.00.0000.01716.82
7.2.330.0070.01116.46
7.2.320.0100.00616.56
7.2.310.0100.00716.54
7.2.300.0050.01316.81
7.2.290.0170.00616.64
7.2.240.0040.01415.21
7.2.230.0080.00815.32
7.2.220.0100.00315.22
7.2.210.0090.00915.34
7.2.200.0060.00615.06
7.2.190.0040.00914.93
7.2.180.0000.01115.19
7.2.170.0060.00914.94
7.2.160.0050.00515.16
7.2.150.0030.01016.89
7.2.140.0060.00616.91
7.2.130.0040.01217.02
7.2.120.0000.01416.94
7.2.110.0030.01016.98
7.2.100.0000.01016.83
7.2.90.0060.00616.79
7.2.80.0000.01417.09
7.2.70.0060.00616.87
7.2.60.0050.01016.91
7.2.50.0100.00317.02
7.2.40.0000.01216.96
7.2.30.0030.01316.96
7.2.20.0040.01117.12
7.2.10.0040.00817.07
7.2.00.0000.01417.14
7.1.330.0030.01015.90
7.1.320.0030.01015.88
7.1.310.0110.00415.87
7.1.300.0040.00815.88
7.1.290.0070.00315.52
7.1.280.0060.00615.83
7.1.270.0040.00815.55
7.1.260.0070.00315.77
7.1.250.0060.00915.88
7.1.200.0030.00715.65
7.1.70.0000.00816.92
7.1.60.0000.01416.96
7.1.50.0030.00716.77
7.1.40.0060.00616.50
7.1.30.0040.00816.60
7.1.20.0090.00316.52
7.1.10.0000.01016.67
7.1.00.0030.00616.59
7.0.200.0000.00816.85
7.0.190.0000.00716.77
7.0.180.0000.00816.20
7.0.170.0060.00316.42
7.0.160.0070.00016.16
7.0.150.0070.00416.30
7.0.140.0040.00416.23
7.0.130.0000.01016.65
7.0.120.0000.00816.53
7.0.110.0060.00316.41
7.0.100.0040.00816.48
7.0.90.0030.00516.39
7.0.80.0060.00916.47
7.0.70.0030.00616.49
7.0.60.0040.00416.21
7.0.50.0000.00816.51
7.0.40.0030.00914.66
7.0.30.0040.00414.66
7.0.20.0040.00414.66
7.0.10.0040.00414.66
7.0.00.0040.00414.66
5.6.300.0100.04120.68
5.6.290.0070.06620.72
5.6.280.0330.03021.02
5.6.270.0070.05621.07
5.6.260.0030.07620.91
5.6.250.0000.04420.88
5.6.240.0000.08920.88
5.6.230.0000.04820.88
5.6.220.0100.06120.92
5.6.210.0030.04220.68
5.6.200.0130.03620.87
5.6.190.0060.04121.04
5.6.180.0030.08220.91
5.6.170.0000.04820.83
5.6.160.0090.03820.92
5.6.150.0240.04420.75
5.6.140.0060.04220.78
5.6.130.0030.04121.00
5.6.120.0000.04521.00
5.6.110.0070.04321.01
5.6.100.0040.04220.86
5.6.90.0030.04621.06
5.6.80.0030.06520.20
5.6.70.0100.06620.41
5.6.60.0030.07520.14
5.6.50.0030.05120.28
5.6.40.0030.07420.38
5.6.30.0000.08620.36
5.6.20.0130.05320.14
5.6.10.0070.03720.23
5.6.00.0070.05820.43

preferences:
31.21 ms | 403 KiB | 5 Q