3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getBatchSize($n) { if ($n <= 100) return false; for ($k = 1; $k <= 50; $k++) { // number of batches without the last (remainder) batch $x = floor((100.0 / (float)$k) - 1); // batch-size wihout the last batch $b = floor($n / $x); // remainder (batch-size of the last batch) $r = $n - ($b * $x); // remainder-limit (the acceptable remainder-size) $rl = ceil(($n / $x) * 2.0); if ($r <= $rl) break; } $pInc = floor(100.0 / $x); $pSum = $pInc * $x; $pR = 100 - $pSum; return array( 'b' => $b, 'x' => $x, 'r' => $r, 'pInc' => $pInc, 'pSum' => $pSum, 'pR' => $pR ); } $n = 101; $res = getBatchSize($n); if ($res === false) { printResult("n <= 100"); return; } echo "Resolve for n = " . $n . "<br />=> b = " . $res['b'] . ", x = " . $res['x'] . ", r = " . $res['r'] . ", pInc = " . $res['pInc'] . ", pSum = " . $res['pSum'] . ", pR = " . $res['pR']; echo "<br />"; for ($k = 1; $k <= 50; $k++) { $x = floor((100.0 / (float)$k) - 1.0); $b = floor($n / $x); $r = $n - ($b * $x); $rl = ceil(($n / $x) * 2.0); // $str = "k = " . $k; $str .= ", b = " . $b; $str .= ", x = " . $x; $str .= ": (" . $r . ' ≤ ' . $rl . ")"; if ($r <= $rl) $str .= " => [OK]"; echo '<br />' . $str; }

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.0080.00818.43
8.3.50.0170.00322.05
8.3.40.0060.01218.97
8.3.30.0070.00719.35
8.3.20.0040.00420.51
8.3.10.0080.00023.59
8.3.00.0050.00319.27
8.2.180.0000.01518.29
8.2.170.0130.00322.96
8.2.160.0150.00019.63
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0000.00826.16
8.2.120.0040.00421.07
8.2.110.0090.00022.35
8.2.100.0070.00417.84
8.2.90.0000.00819.17
8.2.80.0030.00517.97
8.2.70.0030.00617.63
8.2.60.0040.00717.93
8.2.50.0080.00018.07
8.2.40.0040.00418.41
8.2.30.0030.00518.16
8.2.20.0040.00417.91
8.2.10.0040.00418.15
8.2.00.0050.00217.89
8.1.280.0060.00825.92
8.1.270.0030.00519.04
8.1.260.0090.00026.35
8.1.250.0080.00028.09
8.1.240.0060.00323.88
8.1.230.0080.00319.21
8.1.220.0000.00717.77
8.1.210.0000.00918.77
8.1.200.0080.00417.23
8.1.190.0080.00017.23
8.1.180.0000.00818.10
8.1.170.0030.00618.71
8.1.160.0000.00722.11
8.1.150.0050.00218.99
8.1.140.0000.00719.21
8.1.130.0000.00717.89
8.1.120.0030.00517.46
8.1.110.0000.00817.54
8.1.100.0030.00517.53
8.1.90.0000.00817.54
8.1.80.0040.00417.54
8.1.70.0000.00717.61
8.1.60.0080.00017.57
8.1.50.0030.00617.62
8.1.40.0050.00317.65
8.1.30.0050.00317.68
8.1.20.0040.00417.82
8.1.10.0040.00417.54
8.1.00.0080.00017.58
8.0.300.0040.00418.77
8.0.290.0000.00716.75
8.0.280.0070.00018.54
8.0.270.0000.00717.36
8.0.260.0050.00217.40
8.0.250.0000.00716.99
8.0.240.0000.00717.05
8.0.230.0000.00717.11
8.0.220.0040.00417.04
8.0.210.0060.00316.90
8.0.200.0000.00717.03
8.0.190.0090.00017.08
8.0.180.0000.00716.93
8.0.170.0000.00917.04
8.0.160.0060.00316.97
8.0.150.0000.00716.91
8.0.140.0040.00416.97
8.0.130.0000.00613.38
8.0.120.0000.00816.92
8.0.110.0000.00716.99
8.0.100.0050.00216.85
8.0.90.0040.00416.88
8.0.80.0060.01216.88
8.0.70.0030.00516.94
8.0.60.0050.00216.86
8.0.50.0040.00416.86
8.0.30.0090.01617.17
8.0.20.0120.00917.40
8.0.10.0040.00416.92
8.0.00.0130.00516.83
7.4.330.0000.00615.03
7.4.320.0040.00416.59
7.4.300.0000.00716.55
7.4.290.0040.00416.62
7.4.280.0000.00816.64
7.4.270.0000.00716.71
7.4.260.0030.00316.58
7.4.250.0000.01016.56
7.4.240.0040.00316.66
7.4.230.0000.00716.71
7.4.220.0030.01416.68
7.4.210.0040.01116.59
7.4.200.0050.00216.40
7.4.160.0110.00416.53
7.4.150.0170.00917.40
7.4.140.0070.01417.86
7.4.130.0090.00916.53
7.4.120.0130.00516.62
7.4.110.0100.01316.68
7.4.100.0070.01116.75
7.4.90.0070.01116.64
7.4.80.0100.01019.39
7.4.70.0220.00416.69
7.4.60.0080.00816.70
7.4.50.0030.00616.58
7.4.40.0110.01416.78
7.4.30.0110.00916.46
7.4.00.0060.00915.07
7.3.330.0000.00613.39
7.3.320.0000.00613.29
7.3.310.0000.00716.48
7.3.300.0030.00316.33
7.3.290.0050.00916.46
7.3.280.0050.01516.46
7.3.270.0070.01317.40
7.3.260.0130.00616.45
7.3.250.0120.01216.53
7.3.240.0130.00916.66
7.3.230.0130.00916.41
7.3.210.0090.00916.47
7.3.200.0120.00919.39
7.3.190.0130.00416.70
7.3.180.0030.01916.27
7.3.170.0140.00316.74
7.3.160.0180.00616.43
7.3.120.0030.01614.55
7.3.110.0070.00715.19
7.3.100.0070.00714.83
7.3.90.0070.00714.75
7.3.80.0000.01315.00
7.3.70.0080.00314.93
7.3.60.0070.00715.03
7.3.50.0000.01314.79
7.3.40.0070.00714.66
7.3.30.0070.00714.99
7.3.20.0070.01016.44
7.3.10.0110.00916.74
7.3.00.0080.01116.41
7.2.330.0060.01516.69
7.2.320.0090.00916.67
7.2.310.0030.01316.69
7.2.300.0110.01116.66
7.2.290.0100.00816.83
7.2.240.0030.00615.26
7.2.230.0030.01015.28
7.2.220.0070.00714.70
7.2.210.0030.01015.02
7.2.200.0030.01014.97
7.2.190.0090.00015.04
7.2.180.0040.01115.22
7.2.170.0090.00615.04
7.2.160.0040.01215.05
7.2.150.0040.00717.03
7.2.140.0070.00717.01
7.2.130.0070.00916.89
7.2.120.0060.01116.52
7.2.110.0080.00616.72
7.2.100.0080.00516.96
7.2.90.0130.00816.52
7.2.80.0080.00816.81
7.2.70.0130.00517.01
7.2.60.0060.01116.61
7.2.50.0100.01117.00
7.2.40.0160.00316.60
7.2.30.0050.01016.80
7.2.20.0100.00916.81
7.2.10.0130.00916.63
7.2.00.0070.01117.59
7.1.330.0060.00915.95
7.1.320.0070.01015.85
7.1.310.0000.01315.95
7.1.300.0060.00915.69
7.1.290.0000.00915.77
7.1.280.0000.01115.84
7.1.270.0040.00815.77
7.1.260.0080.00815.74
7.1.250.0100.00615.84
7.1.100.0030.01318.20
7.1.70.0000.00717.40
7.1.60.0170.00719.46
7.1.50.0100.01317.01
7.1.00.0030.07722.45
7.0.200.0030.00616.62
7.0.140.0070.05321.95
7.0.60.0070.04319.87
7.0.50.0070.08317.89
7.0.40.0100.08320.15
7.0.30.0330.06020.27
7.0.20.0330.07320.07
7.0.10.0070.08720.10
7.0.00.0030.04320.07
5.6.280.0000.07721.00
5.6.210.0130.06020.68
5.6.200.0100.07318.16
5.6.190.0070.08020.50
5.6.180.0470.04020.67
5.6.170.0230.05020.71
5.6.160.0000.05320.43
5.6.150.0130.07318.16
5.6.140.0130.07318.13
5.6.130.0030.04318.23
5.6.120.0130.05721.05
5.6.110.0000.05021.04
5.6.100.0100.08321.02
5.6.90.0070.08320.98
5.6.80.0100.07720.39
5.5.350.0100.03320.39
5.5.340.0100.05317.94
5.5.330.0130.08320.57
5.5.320.0100.06720.27
5.5.310.0470.06020.37
5.5.300.0070.06017.98
5.5.290.0070.08017.95
5.5.280.0030.05720.89
5.5.270.0000.04720.80
5.5.260.0000.04320.88
5.5.250.0070.08720.63
5.5.240.0300.06320.30
5.4.450.0100.03319.48
5.4.440.0070.04019.46
5.4.430.0000.04319.40
5.4.420.0030.05719.55
5.4.410.0000.05319.14
5.4.400.0130.04019.27
5.4.390.0000.04019.09
5.4.380.0030.05318.94
5.4.370.0000.05319.20
5.4.360.0000.06319.09
5.4.350.0030.06718.98
5.4.340.0030.07718.85
5.4.320.0070.04319.32
5.4.310.0070.05718.86
5.4.300.0000.08018.99
5.4.290.0000.07019.22
5.4.280.0030.08019.08
5.4.270.0030.05718.85
5.4.260.0030.07719.08
5.4.250.0000.08018.85
5.4.240.0000.05019.24
5.4.230.0000.04719.08
5.4.220.0030.05019.09
5.4.210.0070.05018.94
5.4.200.0030.06019.23
5.4.190.0030.04319.12
5.4.180.0070.07018.98
5.4.170.0000.05319.15
5.4.160.0000.04319.20
5.4.150.0000.04019.05
5.4.140.0000.06016.41
5.4.130.0130.05316.36
5.4.120.0070.03016.41
5.4.110.0030.04316.61
5.4.100.0070.06716.50
5.4.90.0000.06716.61
5.4.80.0030.04016.49
5.4.70.0000.07316.58
5.4.60.0030.04316.54
5.4.50.0030.07016.16
5.4.40.0100.03716.25
5.4.30.0030.07016.48
5.4.20.0030.04716.54
5.4.10.0100.07016.55
5.4.00.0030.06315.96
5.3.290.0000.07014.65
5.3.280.0030.07314.77
5.3.270.0030.07014.70
5.3.260.0000.04014.54
5.3.250.0000.04014.53
5.3.240.0130.05714.52
5.3.230.0070.05014.58
5.3.220.0000.07314.80
5.3.210.0000.04314.55
5.3.200.0030.04014.63
5.3.190.0030.05714.66
5.3.180.0100.07314.48
5.3.170.0070.07014.50
5.3.160.0030.04714.58
5.3.150.0030.07314.69
5.3.140.0000.07714.47
5.3.130.0030.07014.53
5.3.120.0000.07714.58
5.3.110.0030.08014.59
5.3.100.0070.07313.95
5.3.90.0070.06314.15
5.3.80.0070.06013.96
5.3.70.0000.07713.95
5.3.60.0000.05713.92
5.3.50.0000.05013.89
5.3.40.0070.06013.89
5.3.30.0130.05013.82
5.3.20.0000.07313.92
5.3.10.0100.05313.59
5.3.00.0000.05313.58
5.2.170.0030.06012.05
5.2.160.0000.04312.05
5.2.150.0000.04312.05
5.2.140.0000.04712.05
5.2.130.0030.06312.05
5.2.120.0030.03312.05
5.2.110.0030.05312.05
5.2.100.0030.06012.05
5.2.90.0030.04712.05
5.2.80.0070.03312.05
5.2.70.0000.04712.05
5.2.60.0070.03312.05
5.2.50.0000.07012.05
5.2.40.0070.05012.05
5.2.30.0000.06712.05
5.2.20.0070.03312.05
5.2.10.0030.06312.05
5.2.00.0000.06312.05
5.1.60.0000.05712.05
5.1.50.0030.04012.05
5.1.40.0000.04712.05
5.1.30.0070.03712.05
5.1.20.0030.03312.05
5.1.10.0030.02712.05
5.1.00.0000.06012.05
5.0.50.0000.04712.05
5.0.40.0030.04012.05
5.0.30.0000.06312.05
5.0.20.0000.03312.05
5.0.10.0000.03712.05
5.0.00.0030.06312.05
4.4.90.0070.03012.05
4.4.80.0000.02012.05
4.4.70.0000.01712.05
4.4.60.0030.03712.05
4.4.50.0070.02312.05
4.4.40.0000.05312.05
4.4.30.0030.01712.05
4.4.20.0000.04012.05
4.4.10.0000.01712.05
4.4.00.0030.03712.05
4.3.110.0030.03312.05
4.3.100.0030.03312.05
4.3.90.0030.03012.05
4.3.80.0030.05012.05
4.3.70.0030.03312.05
4.3.60.0000.02312.05
4.3.50.0030.03312.05
4.3.40.0030.05312.05
4.3.30.0030.02312.05
4.3.20.0000.03712.05
4.3.10.0000.03712.05
4.3.00.0030.03312.05

preferences:
51.64 ms | 401 KiB | 5 Q