3v4l.org

run code in 300+ PHP versions simultaneously
<?php function knapsackLight($value1, $weight1, $value2, $weight2, $maxW) { $results[0] = $maxW >= $weight1 ? $value1 : 0; $results[1] = $maxW >= $weight2 ? $value2 : 0; $results[2] = $maxW >= $weight1 + $weight2 ? $value1 + $value2 : 0; return max($results); } echo knapsackLight(10,5,6,4,8) . PHP_EOL; //10 echo knapsackLight(10,5,6,4,9) . PHP_EOL; //16 echo knapsackLight(5,3,7,4,6) . PHP_EOL; // 7

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.0040.00416.57
8.3.120.0060.00319.07
8.3.110.0160.00420.94
8.3.100.0030.00618.18
8.3.90.0150.00316.58
8.3.80.0060.00317.97
8.3.70.0060.01018.43
8.3.60.0140.00018.31
8.3.50.0140.00518.08
8.3.40.0110.00718.67
8.3.30.0000.01418.61
8.3.20.0080.00020.48
8.3.10.0030.00520.30
8.3.00.0040.00423.65
8.2.250.0040.01116.45
8.2.240.0100.00716.41
8.2.230.0040.00422.58
8.2.220.0060.00324.06
8.2.210.0090.00926.77
8.2.200.0110.00018.16
8.2.190.0100.01016.63
8.2.180.0120.00618.54
8.2.170.0070.01022.96
8.2.160.0070.00720.50
8.2.150.0050.00324.18
8.2.140.0050.00224.66
8.2.130.0070.00026.16
8.2.120.0040.00426.16
8.2.110.0030.00622.10
8.2.100.0080.00417.91
8.2.90.0000.00720.48
8.2.80.0080.00317.97
8.2.70.0050.00317.93
8.2.60.0040.00418.09
8.2.50.0000.00718.10
8.2.40.0040.00419.34
8.2.30.0000.00719.18
8.2.20.0040.00418.17
8.2.10.0000.00719.23
8.2.00.0000.00719.13
8.1.300.0080.00016.10
8.1.290.0090.00018.88
8.1.280.0090.00625.92
8.1.270.0040.00420.87
8.1.260.0070.00026.35
8.1.250.0080.00028.09
8.1.240.0030.00622.09
8.1.230.0070.00320.83
8.1.220.0040.00417.78
8.1.210.0030.00719.03
8.1.200.0070.00317.35
8.1.190.0060.00317.35
8.1.180.0030.00518.10
8.1.170.0080.00018.55
8.1.160.0080.00018.87
8.1.150.0030.00518.83
8.1.140.0070.00020.78
8.1.130.0000.00720.04
8.1.120.0050.00317.39
8.1.110.0040.00417.27
8.1.100.0080.00017.29
8.1.90.0030.00917.35
8.1.80.0040.00417.22
8.1.70.0030.00517.36
8.1.60.0040.00417.56
8.1.50.0060.00317.32
8.1.40.0040.00417.45
8.1.30.0080.00017.44
8.1.20.0060.00317.60
8.1.10.0000.00717.54
8.1.00.0060.00317.30
8.0.300.0070.00019.91
8.0.290.0040.00416.63
8.0.280.0040.00418.44
8.0.270.0030.00516.75
8.0.260.0000.00619.93
8.0.250.0030.00316.77
8.0.240.0000.00716.91
8.0.230.0000.00716.86
8.0.220.0060.00016.76
8.0.210.0000.00716.86
8.0.200.0030.00316.92
8.0.190.0040.00416.81
8.0.180.0040.00416.82
8.0.170.0030.00516.72
8.0.160.0000.00716.86
8.0.150.0070.00316.83
8.0.140.0040.00416.69
8.0.130.0000.00713.34
8.0.120.0050.00316.68
8.0.110.0030.00316.86
8.0.100.0000.00716.68
8.0.90.0000.00716.71
8.0.80.0070.01316.84
8.0.70.0070.00016.73
8.0.60.0090.00016.73
8.0.50.0050.00316.80
8.0.30.0130.00517.26
8.0.20.0120.00616.94
8.0.10.0040.00417.00
8.0.00.0090.01016.72
7.4.330.0050.00015.55
7.4.320.0030.00316.43
7.4.300.0030.00316.39
7.4.290.0040.00416.44
7.4.280.0040.00416.47
7.4.270.0030.00316.50
7.4.260.0060.00013.24
7.4.250.0030.00516.55
7.4.240.0080.00016.43
7.4.230.0070.00016.69
7.4.220.0040.00316.65
7.4.210.0030.01116.61
7.4.200.0030.00316.52
7.4.130.0230.00716.39
7.4.120.0070.01116.73
7.4.110.0040.01416.35
7.4.100.0030.01316.58
7.4.90.0080.00816.41
7.4.80.0140.00719.39
7.4.70.0080.00916.48
7.4.60.0060.01016.40
7.4.50.0110.00316.13
7.4.40.0040.01616.51
7.4.10.0060.00614.91
7.4.00.0070.00914.96
7.3.330.0030.00316.25
7.3.320.0060.00013.35
7.3.310.0030.00316.18
7.3.300.0000.00716.28
7.3.290.0000.00716.37
7.3.280.0130.00716.30
7.3.260.0130.00916.53
7.3.240.0070.01016.53
7.3.230.0060.01016.25
7.3.210.0100.00716.50
7.3.200.0110.00716.61
7.3.190.0090.00616.61
7.3.180.0090.01416.29
7.3.170.0030.01216.49
7.3.160.0030.01316.27
7.3.130.0070.00914.86
7.3.120.0100.00814.79
7.3.110.0080.01014.82
7.3.100.0070.00614.95
7.3.90.0120.00515.13
7.3.80.0060.00914.86
7.3.70.0080.00814.74
7.3.60.0040.01314.84
7.3.50.0060.00914.68
7.3.40.0090.00514.74
7.3.30.0080.00314.70
7.3.20.0070.00916.64
7.3.10.0080.00416.74
7.3.00.0080.00616.60
7.2.330.0140.00316.36
7.2.320.0150.00316.46
7.2.310.0110.01116.68
7.2.300.0100.00616.37
7.2.290.0100.00716.57
7.2.260.0110.00715.09
7.2.250.0050.01314.96
7.2.240.0050.01015.09
7.2.230.0090.00614.82
7.2.220.0080.00715.03
7.2.210.0050.01014.97
7.2.200.0020.00814.89
7.2.190.0080.00814.99
7.2.180.0060.00915.04
7.2.170.0040.01014.95
7.2.160.0100.00414.90
7.2.150.0060.00816.68
7.2.140.0070.00716.88
7.2.130.0050.00916.73
7.2.120.0050.00816.84
7.2.110.0040.00716.57
7.2.100.0070.00516.68
7.2.90.0080.00816.73
7.2.80.0110.00616.93
7.2.70.0090.00516.70
7.2.60.0060.01016.79
7.2.50.0080.00616.78
7.2.40.0040.01117.04
7.2.30.0110.00216.88
7.2.20.0090.00516.81
7.2.10.0090.00616.68
7.2.00.0050.00916.79
7.1.330.0020.01115.71
7.1.320.0060.00815.97
7.1.310.0080.00515.67
7.1.300.0090.00715.65
7.1.290.0040.00915.76
7.1.280.0040.00915.74
7.1.270.0060.00615.76
7.1.260.0050.00915.60
7.1.250.0040.00715.74
7.1.240.0070.00715.86
7.1.230.0060.00315.88
7.1.220.0060.00915.96
7.1.210.0080.00315.97
7.1.200.0040.00815.61
7.1.190.0000.01415.84
7.1.180.0070.00715.61
7.1.170.0060.00915.65
7.1.160.0000.01515.79
7.1.150.0000.01115.77
7.1.140.0070.00715.61
7.1.130.0060.01015.91
7.1.120.0070.00715.49
7.1.110.0090.00615.89
7.1.100.0000.00915.87
7.1.90.0040.00415.63
7.1.80.0030.00616.04
7.1.70.0080.00615.95
7.1.60.0090.00315.80
7.1.50.0060.00615.96
7.1.40.0040.01115.84
7.1.30.0000.01215.75
7.1.20.0040.00716.03
7.1.10.0000.01315.82
7.1.00.0120.00315.77

preferences:
70.09 ms | 403 KiB | 5 Q