3v4l.org

run code in 300+ PHP versions simultaneously
<?php test(2000); test(1845); test(2340); test(3000); // Examples: // Door 2000 1845 3000 // 615mm panel 1 3 5 // 495mm panel 3 0 0 // panel loss 100 0 75 function calcOptimalPanels ($doorHeight) { $bigHeight = 615; $smallHeight = 495; $bigFit = floor($doorHeight / $bigHeight); $smallFit = floor($doorHeight / $smallHeight); $options = []; for ($big = 0; $big <= $bigFit; $big++) { for ($small = 0; $small <= $smallFit; $small++) { $waste = $bigHeight * $big + $smallHeight * $small - $doorHeight; if ($waste === 0) // Get first combination without waste return getFormattedResult($big, $small, $waste); if ($waste < 0) // Omit combinations smaller then door continue; $options[$waste] = getFormattedResult($big, $small, $waste); } } $minWaste = min(array_keys($options)); return $options[$minWaste]; } function getFormattedResult($big, $small, $waste) { return ['615mm' => $big, '495mm' => $small, 'waste' => $waste]; } function test($doorHeight) { echo $doorHeight . ': ' . json_encode(calcOptimalPanels($doorHeight)) . "\n"; }

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.4.120.0100.01024.01
8.4.110.0110.00922.62
8.4.100.0060.00917.85
8.4.90.0050.00620.50
8.4.80.0120.00817.74
8.4.70.0100.01217.75
8.4.60.0130.00718.69
8.4.50.0100.00820.31
8.4.40.0100.00617.73
8.4.30.0180.00317.42
8.4.20.0150.00719.54
8.4.10.0030.00619.40
8.3.250.0110.00818.72
8.3.240.0040.00419.31
8.3.230.0060.00616.81
8.3.220.0050.00319.10
8.3.210.0100.01018.60
8.3.200.0050.00416.46
8.3.190.0040.00317.37
8.3.180.0140.00516.36
8.3.170.0120.00617.30
8.3.160.0140.00320.18
8.3.150.0080.01117.23
8.3.140.0110.00417.06
8.3.130.0060.00318.43
8.3.120.0060.00320.59
8.3.110.0120.00320.94
8.3.100.0040.00424.06
8.3.90.0040.00426.77
8.3.80.0060.00619.36
8.3.70.0120.00318.55
8.3.60.0070.00718.20
8.3.50.0110.00718.32
8.3.40.0160.00318.91
8.3.30.0110.00318.84
8.3.20.0040.00420.33
8.3.10.0080.00021.90
8.3.00.0000.00819.50
8.2.290.0130.00420.30
8.2.280.0130.00618.52
8.2.270.0120.00617.18
8.2.260.0040.00418.97
8.2.250.0030.00616.44
8.2.240.0090.00016.94
8.2.230.0060.00322.58
8.2.220.0160.00337.54
8.2.210.0070.00026.77
8.2.200.0000.01018.88
8.2.190.0140.00416.58
8.2.180.0160.00618.29
8.2.170.0130.00622.96
8.2.160.0060.01222.10
8.2.150.0040.00424.18
8.2.140.0030.00724.66
8.2.130.0000.00826.16
8.2.120.0070.00019.89
8.2.110.0050.00522.38
8.2.100.0100.00017.97
8.2.90.0030.00522.32
8.2.80.0080.00017.97
8.2.70.0030.00618.18
8.2.60.0040.00418.28
8.2.50.0000.00818.10
8.2.40.0030.00517.72
8.2.30.0040.00419.30
8.2.20.0070.00318.13
8.2.10.0000.00818.18
8.2.00.0040.00418.37
8.1.330.0120.00721.79
8.1.320.0110.00816.01
8.1.310.0120.00616.76
8.1.300.0150.00320.06
8.1.290.0050.00530.84
8.1.280.0120.00325.92
8.1.270.0050.00524.66
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0000.00922.55
8.1.230.0040.00820.91
8.1.220.0000.00917.80
8.1.210.0000.00819.08
8.1.200.0050.00517.47
8.1.190.0000.00917.25
8.1.180.0040.00418.10
8.1.170.0050.00318.62
8.1.160.0000.00718.95
8.1.150.0040.00418.95
8.1.140.0000.00817.75
8.1.130.0030.00318.82
8.1.120.0070.00417.42
8.1.110.0060.00517.40
8.1.100.0110.00017.56
8.1.90.0070.00017.54
8.1.80.0030.00517.50
8.1.70.0080.00017.42
8.1.60.0030.00517.54
8.1.50.0070.00017.46
8.1.40.0070.00017.50
8.1.30.0080.00017.61
8.1.20.0030.00517.62
8.1.10.0030.00617.68
8.1.00.0000.00717.57
8.0.300.0000.00820.11
8.0.290.0070.00316.75
8.0.280.0000.00718.43
8.0.270.0000.00717.17
8.0.260.0030.00316.79
8.0.250.0000.00717.00
8.0.240.0030.00617.02
8.0.230.0040.00417.00
8.0.220.0050.00516.89
8.0.210.0030.00316.91
8.0.200.0000.00816.97
8.0.190.0050.00317.02
8.0.180.0030.00316.88
8.0.170.0040.00816.93
8.0.160.0040.00417.05
8.0.150.0030.00716.91
8.0.140.0040.00416.93
8.0.130.0030.00313.39
8.0.120.0050.00316.91
8.0.110.0070.00016.92
8.0.100.0040.00416.96
8.0.90.0000.00816.96
8.0.80.0160.00416.99
8.0.70.0000.00817.00
8.0.60.0050.00216.78
8.0.50.0030.00517.02
8.0.30.0090.01016.95
8.0.20.0130.00717.41
8.0.10.0000.00817.09
8.0.00.0080.01316.85
7.4.330.0000.00515.55
7.4.320.0000.00716.57
7.4.300.0070.00016.61
7.4.290.0040.00416.57
7.4.280.0030.00616.67
7.4.270.0030.00316.66
7.4.260.0000.00816.55
7.4.250.0050.00216.63
7.4.240.0040.00416.71
7.4.230.0030.00316.46
7.4.220.0040.00416.45
7.4.210.0090.00816.59
7.4.200.0030.00316.46
7.4.160.0090.00816.66
7.4.150.0150.00917.40
7.4.140.0100.01017.86
7.4.130.0130.00616.70
7.4.120.0090.01216.57
7.4.110.0070.01016.51
7.4.100.0090.00916.60
7.4.90.0070.01016.66
7.4.80.0120.00619.39
7.4.70.0060.01216.61
7.4.60.0060.01216.69
7.4.50.0110.00716.32
7.4.40.0030.01516.56
7.4.10.0070.01114.82
7.4.00.0020.01515.01
7.3.330.0050.00013.45
7.3.320.0000.00613.43
7.3.310.0000.00716.54
7.3.300.0000.00616.39
7.3.290.0030.00316.46
7.3.280.0130.00116.42
7.3.270.0070.01117.40
7.3.260.0080.01016.43
7.3.250.0100.00916.60
7.3.240.0120.00816.62
7.3.230.0000.01716.73
7.3.210.0070.01016.48
7.3.200.0060.00916.50
7.3.190.0120.00316.55
7.3.180.0090.01516.36
7.3.170.0110.00716.55
7.3.160.0120.00916.57
7.3.130.0080.01215.05
7.3.120.0110.00514.72
7.3.110.0090.00614.59
7.3.100.0050.01014.77
7.3.90.0050.00714.87
7.3.80.0020.00914.91
7.3.70.0030.01114.82
7.3.60.0070.00814.85
7.3.50.0030.01014.68
7.3.40.0040.00614.86
7.3.30.0080.00414.80
7.3.20.0050.00916.62
7.3.10.0080.00816.68
7.3.00.0100.00616.76
7.2.330.0070.01116.82
7.2.320.0100.01316.89
7.2.310.0140.00516.86
7.2.300.0170.00316.77
7.2.290.0070.01016.83
7.2.260.0070.01114.86
7.2.250.0030.00815.33
7.2.240.0060.00914.99
7.2.230.0020.01414.97
7.2.220.0030.01314.98
7.2.210.0070.00815.21
7.2.200.0020.01115.24
7.2.190.0070.00815.01
7.2.180.0020.00914.94
7.2.170.0050.00815.16
7.2.160.0040.00914.99
7.2.150.0060.00616.66
7.2.140.0090.00516.97
7.2.130.0050.01016.95
7.2.120.0040.01016.97
7.2.110.0070.00717.03
7.2.100.0070.00716.99
7.2.90.0090.00516.71
7.2.80.0030.00817.05
7.2.70.0050.01016.95
7.2.60.0060.01016.88
7.2.50.0070.00916.63
7.2.40.0040.00816.89
7.2.30.0090.00516.86
7.2.20.0090.00716.99
7.2.10.0070.01217.26
7.2.00.0390.00917.33
7.1.330.0060.00715.63
7.1.320.0080.00415.93
7.1.310.0060.00615.57
7.1.300.0080.00815.51
7.1.290.0110.00215.63
7.1.280.0050.01115.73
7.1.270.0030.00815.74
7.1.260.0050.00915.71
7.1.250.0070.00415.52
7.1.240.0030.01015.89
7.1.230.0090.00315.61
7.1.220.0040.00815.77
7.1.210.0030.00615.88
7.1.200.0070.00315.86
7.1.190.0040.01515.64
7.1.180.0100.00615.73
7.1.170.0150.00015.79
7.1.160.0030.00915.85
7.1.150.0090.00615.61
7.1.140.0060.00615.80
7.1.130.0140.00916.27
7.1.120.0080.01016.18
7.1.110.0080.01015.89
7.1.100.0080.00916.05
7.1.90.0120.00715.90
7.1.80.0110.00916.03
7.1.70.0110.00815.61
7.1.60.0150.01024.53
7.1.50.0130.01124.44
7.1.40.0200.01124.31
7.1.30.0200.01224.25
7.1.20.0220.01224.25
7.1.10.0100.00715.27
7.1.00.0150.00715.34
7.0.330.0120.00015.25
7.0.320.0040.00814.92
7.0.310.0030.00715.41
7.0.300.0060.00615.14
7.0.290.0030.00615.33
7.0.280.0090.00315.03
7.0.270.0070.00315.34
7.0.260.0090.00314.95
7.0.250.0060.00615.32
7.0.240.0030.00815.12
7.0.230.0030.00615.36
7.0.220.0060.00815.39
7.0.210.0060.00615.54
7.0.200.0030.00515.20
7.0.190.0030.00615.46
7.0.180.0070.00415.47
7.0.170.0040.00715.44
7.0.160.0090.00615.45
7.0.150.0000.01215.36
7.0.140.0000.01115.40
7.0.130.0060.00915.39
7.0.120.0030.00615.53
7.0.110.0000.01015.25
7.0.100.0080.00615.32
7.0.90.0030.00715.47
7.0.80.0000.01215.33
7.0.70.0000.01415.46
7.0.60.0090.00615.41
7.0.50.0030.00715.43
7.0.40.0060.00613.42
7.0.30.0080.00313.45
7.0.20.0060.00613.40
7.0.10.0000.01013.56
7.0.00.0060.00613.44
5.6.400.0090.00913.77
5.6.390.0080.00414.43
5.6.380.0060.00314.27
5.6.370.0120.00314.79
5.6.360.0000.01714.13
5.6.350.0100.00314.08
5.6.340.0030.01214.43
5.6.330.0110.00013.99
5.6.320.0030.01314.27
5.6.310.0030.00614.49
5.6.300.0030.00914.61
5.6.290.0070.00714.43
5.6.280.0030.00714.81
5.6.270.0000.01214.59
5.6.260.0070.00714.50
5.6.250.0040.01214.79
5.6.240.0040.00414.48
5.6.230.0070.00714.67
5.6.220.0030.01314.71
5.6.210.0060.01014.50
5.6.200.0040.00714.73
5.6.190.0070.00714.35
5.6.180.0030.00914.23
5.6.170.0000.00914.24
5.6.160.0070.00314.50
5.6.150.0050.00514.51
5.6.140.0000.01214.41
5.6.130.0100.00314.73
5.6.120.0060.00914.11
5.6.110.0000.01414.14
5.6.100.0050.00314.30
5.6.90.0050.00514.84
5.6.80.0070.01014.35
5.6.70.0040.00714.31
5.6.60.0080.00414.24
5.6.50.0060.00614.15
5.6.40.0110.00314.16
5.6.30.0050.00314.68
5.6.20.0000.00914.64
5.6.10.0080.00314.33
5.6.00.0000.01714.66

preferences:
19.29 ms | 403 KiB | 5 Q