3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Shipping { /** * @return integer The minimum number of boxes needed to hold a given number of items */ public static function minimalNumberOfPackages($items, $availableLargePackages, $availableSmallPackages) { $maxSize = 5; if ($items < $maxSize) return $items; if (($items - ($maxSize * $availableLargePackages + $availableSmallPackages)) > 0) return -1; $itemsNotHoldByMax = $items / 5; if ($itemsNotHoldByMax > $items) $itemsNotHoldByMax = $availableLargePackages; return $itemsNotHoldByMax + ($items - $maxSize * $itemsNotHoldByMax); } public static function minimalNumberOfBoxes2( $products, $availableLargeBoxes, $availableSmallBoxes) { if ($products < 5) return $products; if (($products - (5 * $availableLargeBoxes + $availableSmallBoxes)) > 0) return -1; $rl = $products / 5; if ($rl > $availableLargeBoxes) $rl = $availableLargeBoxes; return $rl + ($products - 5 * $rl); } } echo Shipping::minimalNumberOfPackages2(16, 2, 10);

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.0150.00018.18
8.3.50.0080.00818.14
8.3.40.0070.00718.79
8.3.30.0070.00718.61
8.3.20.0080.00020.39
8.3.10.0060.00323.61
8.3.00.0050.00319.84
8.2.180.0120.00925.92
8.2.170.0070.00718.79
8.2.160.0070.01022.96
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0080.00020.58
8.2.110.0060.00320.49
8.2.100.0090.00319.43
8.2.90.0000.00817.97
8.2.80.0000.00720.36
8.2.70.0060.00317.90
8.2.60.0040.00417.91
8.2.50.0040.00418.10
8.2.40.0070.00020.41
8.2.30.0030.00619.16
8.2.20.0040.00417.87
8.2.10.0040.00418.07
8.2.00.0000.00718.25
8.1.280.0100.01025.92
8.1.270.0050.00322.18
8.1.260.0030.00526.35
8.1.250.0070.00028.09
8.1.240.0000.00823.79
8.1.230.0080.00420.96
8.1.220.0000.00817.74
8.1.210.0040.00418.77
8.1.200.0080.00017.36
8.1.190.0040.00717.41
8.1.180.0080.00018.10
8.1.170.0050.00318.50
8.1.160.0000.00718.65
8.1.150.0040.00420.27
8.1.140.0040.00417.62
8.1.130.0000.00618.87
8.1.120.0000.00717.34
8.1.110.0030.00517.23
8.1.100.0080.00017.35
8.1.90.0020.00517.34
8.1.80.0000.00717.38
8.1.70.0040.00417.29
8.1.60.0030.00517.52
8.1.50.0030.00517.40
8.1.40.0000.00817.43
8.1.30.0000.00817.58
8.1.20.0070.00417.56
8.1.10.0000.00717.39
8.1.00.0040.00417.49
8.0.300.0040.00420.09
8.0.290.0000.00816.88
8.0.280.0040.00418.39
8.0.270.0000.00717.21
8.0.260.0060.00016.84
8.0.250.0030.00316.96
8.0.240.0000.00716.85
8.0.230.0000.00716.84
8.0.220.0050.00216.91
8.0.210.0040.00416.91
8.0.200.0000.00616.99
8.0.190.0040.00416.97
8.0.180.0020.00516.97
8.0.170.0030.00616.83
8.0.160.0040.00416.90
8.0.150.0040.00416.96
8.0.140.0040.00416.89
8.0.130.0000.00513.29
8.0.120.0050.00216.77
8.0.110.0000.00716.96
8.0.100.0040.00416.88
8.0.90.0040.00416.83
8.0.80.0130.00316.91
8.0.70.0000.00816.77
8.0.60.0000.00816.97
8.0.50.0000.00716.85
8.0.30.0090.00917.06
8.0.20.0140.00417.40
8.0.10.0040.00416.84
8.0.00.0050.01416.72
7.4.330.0050.00015.55
7.4.320.0060.00016.38
7.4.300.0030.00316.57
7.4.290.0030.00616.37
7.4.280.0000.00716.59
7.4.270.0000.00616.56
7.4.260.0040.00416.46
7.4.250.0050.00216.41
7.4.240.0000.00816.53
7.4.230.0030.00316.34
7.4.220.0030.00516.52
7.4.210.0100.01016.60
7.4.200.0070.00016.61
7.4.160.0090.00816.42
7.4.150.0140.00617.40
7.4.140.0120.00717.86
7.4.130.0090.01016.49
7.4.120.0060.01216.48
7.4.110.0140.00416.43
7.4.100.0140.00716.45
7.4.90.0120.00816.45
7.4.80.0100.01319.39
7.4.70.0180.00016.50
7.4.60.0120.00916.49
7.4.50.0030.00916.50
7.4.40.0100.01016.62
7.4.10.0070.01116.39
7.4.00.0100.00515.71
7.3.330.0030.00313.18
7.3.320.0050.00213.29
7.3.310.0030.00316.30
7.3.300.0070.00016.29
7.3.290.0040.00416.27
7.3.280.0050.01116.29
7.3.270.0110.00617.40
7.3.260.0090.00916.50
7.3.250.0050.01116.32
7.3.240.0080.00916.27
7.3.230.0100.00716.41
7.3.210.0090.01216.41
7.3.200.0130.00316.28
7.3.190.0040.01216.27
7.3.180.0140.00316.52
7.3.170.0090.01316.33
7.3.160.0030.01316.54
7.3.130.0090.00916.52
7.3.120.0100.00916.56
7.3.110.0030.01316.30
7.3.100.0110.00815.06
7.3.90.0060.00915.09
7.3.80.0110.00515.10
7.3.70.0130.00315.06
7.3.60.0090.00815.10
7.3.50.0080.00715.04
7.3.40.0100.00515.06
7.3.30.0070.00815.10
7.3.20.0090.00615.18
7.3.10.0050.00915.30
7.3.00.0100.00715.32
7.2.330.0070.01016.60
7.2.320.0110.00616.75
7.2.310.0200.00316.43
7.2.300.0110.00716.56
7.2.290.0070.01016.48
7.2.260.0090.00916.27
7.2.250.0150.00616.35
7.2.240.0110.00716.48
7.2.230.0070.01215.21
7.2.220.0070.01015.16
7.2.210.0050.01015.29
7.2.200.0090.00815.26
7.2.190.0100.00515.20
7.2.180.0070.00815.19
7.2.170.0050.01015.22
7.2.160.0090.00715.31
7.2.150.0050.01115.24
7.2.140.0080.00915.12
7.2.130.0120.00915.53
7.2.120.0110.00815.59
7.2.110.0090.00715.53
7.2.100.0090.00815.55
7.2.90.0070.01115.55
7.2.80.0090.01015.49
7.2.70.0100.00815.53
7.2.60.0050.01015.70
7.2.50.0100.00415.47
7.2.40.0120.00515.61
7.2.30.0100.00915.63
7.2.20.0030.01315.92
7.2.10.0110.01015.92
7.2.00.0090.00915.99
7.1.330.0060.01015.42
7.1.320.0070.00814.16
7.1.310.0070.00714.18
7.1.300.0070.00914.14
7.1.290.0070.00814.10
7.1.280.0040.01014.13
7.1.270.0100.00714.09
7.1.260.0090.01214.08
7.1.250.0100.00714.28
7.1.240.0090.00814.01
7.1.230.0070.01113.95
7.1.220.0110.00614.13
7.1.210.0090.00813.85
7.1.200.0070.01014.34
7.1.190.0090.01014.05
7.1.180.0060.00914.08
7.1.170.0070.00813.98
7.1.160.0090.00813.91
7.1.150.0070.01014.02
7.1.140.0090.00814.68
7.1.130.0150.00914.63
7.1.120.0180.00614.57
7.1.110.0070.01014.61
7.1.100.0190.00714.45
7.1.90.0060.00914.36
7.1.80.0170.00614.47
7.1.70.0200.01014.32
7.1.60.0110.01017.94
7.1.50.0150.01017.80
7.1.40.0140.00617.64
7.1.30.0250.00517.78
7.1.20.0190.01017.79
7.1.10.0150.00814.09
7.1.00.0160.00814.13
7.0.330.0100.00613.83
7.0.320.0080.00813.67
7.0.310.0090.00813.90
7.0.300.0120.00613.95
7.0.290.0080.00813.76
7.0.280.0090.00813.91
7.0.270.0190.00814.48
7.0.260.0170.00514.44
7.0.250.0220.00814.42
7.0.240.0100.00714.14
7.0.230.0100.00614.20
7.0.220.0050.01114.35
7.0.210.0080.00914.13
7.0.200.0170.00814.13
7.0.190.0070.00914.09
7.0.180.0150.01114.05
7.0.170.0230.00613.99
7.0.160.0150.00913.99
7.0.150.0050.01114.20
7.0.140.0220.00613.88
7.0.130.0220.01014.05
7.0.120.0220.00714.16
7.0.110.0190.00714.07
7.0.100.0160.00914.02
7.0.90.0050.01114.06
7.0.80.0190.01114.14
7.0.70.0190.00613.99
7.0.60.0180.00613.90
7.0.50.0140.01214.02
7.0.40.0180.00814.18
7.0.30.0170.00514.11
7.0.20.0130.01014.07
7.0.10.0090.01114.08
7.0.00.0130.01114.12
5.6.400.0090.00714.46
5.6.390.0100.00714.41
5.6.380.0060.01214.31
5.6.370.0120.00714.46
5.6.360.0120.00814.62
5.6.350.0090.01014.56
5.6.340.0090.00714.68
5.6.330.0110.00614.60
5.6.320.0050.01414.52
5.6.310.0110.00614.35
5.6.300.0080.02116.10
5.6.290.0130.01816.09
5.6.280.0100.02216.31
5.6.270.0130.02016.27
5.6.260.0120.02416.28
5.6.250.0090.02616.13
5.6.240.0110.02116.08
5.6.230.0090.02116.23
5.6.220.0100.02316.11
5.6.210.0090.02516.14
5.6.200.0090.02116.27
5.6.190.0100.02316.06
5.6.180.0080.02016.06
5.6.170.0120.02216.08
5.6.160.0090.02316.22
5.6.150.0080.02216.19
5.6.140.0100.02216.21
5.6.130.0090.01916.10
5.6.120.0090.02015.99
5.6.110.0090.02116.21
5.6.100.0160.01516.14
5.6.90.0130.01816.19
5.6.80.0090.01916.08
5.6.70.0070.02715.89
5.6.60.0070.02615.85
5.6.50.0110.02415.96
5.6.40.0100.02115.89
5.6.30.0110.01815.79
5.6.20.0090.02215.99
5.6.10.0120.02016.03
5.6.00.0150.01715.88
5.5.380.0080.00814.45
5.5.370.0120.00514.38
5.5.360.0110.00914.45
5.5.350.0090.00714.51
5.5.340.0090.00814.46
5.5.330.0100.00714.30
5.5.320.0090.00714.42
5.5.310.0060.01014.36
5.5.300.0090.00914.29
5.5.290.0040.01314.60
5.5.280.0070.00814.56
5.5.270.0110.00714.38
5.5.260.0100.01114.35
5.5.250.0110.00714.34
5.5.240.0120.00514.32
5.5.230.0100.01014.53
5.5.220.0060.01114.40
5.5.210.0100.00814.44
5.5.200.0050.01414.34
5.5.190.0120.00914.45
5.5.180.0110.01114.64
5.5.170.0130.00714.29
5.5.160.0070.01414.46
5.5.150.0110.01114.19
5.5.140.0100.00914.46
5.5.130.0070.01214.51
5.5.120.0120.00714.38
5.5.110.0080.01114.38
5.5.100.0110.01214.47
5.5.90.0090.01214.38
5.5.80.0040.01414.37
5.5.70.0120.00514.49
5.5.60.0090.00814.26
5.5.50.0090.01014.35
5.5.40.0110.00714.45
5.5.30.0080.01014.45
5.5.20.0110.00814.43
5.5.10.0090.00914.38
5.5.00.0120.00514.16
5.4.450.0090.00311.16
5.4.440.0060.00511.43
5.4.430.0070.00711.28
5.4.420.0090.00711.40
5.4.410.0040.00711.46
5.4.400.0030.00911.20
5.4.390.0070.00511.23
5.4.380.0060.00711.20
5.4.370.0110.00211.35
5.4.360.0080.00511.18
5.4.350.0070.00611.14
5.4.340.0070.00711.34
5.4.330.0080.00711.21
5.4.320.0100.00511.31
5.4.310.0080.00611.26
5.4.300.0030.01011.28
5.4.290.0080.00811.23
5.4.280.0060.00711.24
5.4.270.0080.00611.18
5.4.260.0090.00711.27
5.4.250.0080.00611.35
5.4.240.0060.00811.13
5.4.230.0040.00511.23
5.4.220.0040.01011.24
5.4.210.0070.00611.29
5.4.200.0090.00611.37
5.4.190.0080.00511.20
5.4.180.0100.00411.36
5.4.170.0070.00511.32
5.4.160.0040.00811.08
5.4.150.0070.00711.17
5.4.140.0070.00811.29
5.4.130.0040.01011.31
5.4.120.0060.00611.25
5.4.110.0020.00911.21
5.4.100.0100.00311.19
5.4.90.0080.00511.33
5.4.80.0080.00611.19
5.4.70.0070.00611.27
5.4.60.0110.00311.36
5.4.50.0070.00511.35
5.4.40.0090.00211.23
5.4.30.0060.00811.34
5.4.20.0010.01311.33
5.4.10.0040.00811.22
5.4.00.0130.00311.21
5.3.290.0060.00911.33
5.3.280.0070.00711.13
5.3.270.0070.00611.21
5.3.260.0030.00911.22
5.3.250.0040.00811.16
5.3.240.0060.00611.02
5.3.230.0060.00611.11
5.3.220.0090.00411.17
5.3.210.0050.00711.10
5.3.200.0090.00411.13
5.3.190.0080.00611.08
5.3.180.0060.00811.34
5.3.170.0100.00411.22
5.3.160.0050.00411.24
5.3.150.0030.01111.33
5.3.140.0070.00811.29
5.3.130.0040.00911.18
5.3.120.0090.00611.08
5.3.110.0060.00611.29
5.3.100.0060.00711.22
5.3.90.0040.00811.30
5.3.80.0060.00711.15
5.3.70.0040.00811.15
5.3.60.0080.00611.29
5.3.50.0060.00911.13
5.3.40.0070.00511.13
5.3.30.0050.00811.11
5.3.20.0070.00711.09
5.3.10.0060.00710.95
5.3.00.0060.00710.91
5.2.170.0000.01010.54
5.2.160.0050.00610.54
5.2.150.0030.00710.52
5.2.140.0080.00610.51
5.2.130.0080.00310.52
5.2.120.0070.00510.51
5.2.110.0080.00510.51
5.2.100.0060.00510.51
5.2.90.0030.00910.54
5.2.80.0080.00410.51
5.2.70.0050.00610.51
5.2.60.0040.00610.51
5.2.50.0040.00610.51
5.2.40.0030.00710.51
5.2.30.0030.00710.56
5.2.20.0080.00310.51
5.2.10.0040.00510.51
5.2.00.0030.00610.51
5.1.60.0040.00510.51
5.1.50.0020.00710.51
5.1.40.0020.00710.51
5.1.30.0050.00410.51
5.1.20.0040.00510.51
5.1.10.0040.00510.51
5.1.00.0060.00510.51
5.0.50.0050.00410.51
5.0.40.0030.00510.51
5.0.30.0050.00310.51
5.0.20.0050.00410.51
5.0.10.0060.00310.51
5.0.00.0070.00110.51
4.4.90.0040.00210.51
4.4.80.0030.00310.51
4.4.70.0010.00510.51
4.4.60.0010.00510.51
4.4.50.0010.00510.51
4.4.40.0020.00410.51
4.4.30.0050.00110.51
4.4.20.0020.00410.51
4.4.10.0020.00510.51
4.4.00.0020.00410.51
4.3.110.0040.00210.51
4.3.100.0030.00310.51
4.3.90.0030.00310.51
4.3.80.0020.00310.51
4.3.70.0030.00310.51
4.3.60.0020.00410.51
4.3.50.0020.00310.51
4.3.40.0040.00210.51
4.3.30.0020.00610.51
4.3.20.0020.00510.51
4.3.10.0040.00310.51
4.3.00.0040.00210.51

preferences:
88.7 ms | 400 KiB | 5 Q