3v4l.org

run code in 300+ PHP versions simultaneously
<?php function oldGetMinPrice($num1, $num2) { if(!(is_numeric($num1) && $num1 >0) && !(is_numeric($num2) && $num2 >0) ) { return 'error'; } $num1 = (float)$num1; $num2 = (float)$num2; echo "($num1 & $num2) "; if($num1 <= 0) { return $num2; } if($num2 <= 0) { return $num1; } return min($num1,$num2); } function newGetMinPrice($nums) { $nums = array_filter($nums, function($v){ return (float)$v > 0;}); // convert to float and check if greater than 0 if (empty($nums)) { return 'error'; // if no qualifying prices, return error } return min($nums); // return the lowest qualifying price } $tests = [[0, .1], [1, 'foo'], [.24, -.25], [3, 3], ['foo', 'bar'], [-0, 0.1], [90, -90], [0, 0], [1, 1]]; foreach ($tests as $test) { echo "old: {$test[0]} -vs- {$test[1]} = ",oldGetMinPrice($test[0], $test[1]), "\n"; echo "new: {$test[0]} -vs- {$test[1]} = ",newGetMinPrice($test), "\n\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.130.0020.00717.71
8.4.120.0130.00820.66
8.4.110.0060.00418.86
8.4.100.0040.00618.00
8.4.90.0110.00917.54
8.4.80.0080.00217.73
8.4.70.0090.00719.34
8.4.60.0130.00918.84
8.4.50.0030.00917.83
8.4.40.0080.00018.00
8.4.30.0090.00019.46
8.4.20.0110.01119.41
8.4.10.0100.00717.42
8.3.250.0110.00818.80
8.3.240.0140.00618.76
8.3.230.0120.00716.53
8.3.220.0100.00718.78
8.3.210.0120.00916.82
8.3.200.0060.00316.61
8.3.190.0100.00617.12
8.3.180.0110.00818.38
8.3.170.0150.00318.84
8.3.160.0150.00418.31
8.3.150.0030.01720.75
8.3.140.0040.00416.80
8.3.130.0090.00016.50
8.3.120.0000.00918.74
8.3.110.0040.00416.41
8.3.100.0070.00024.06
8.3.90.0040.00426.77
8.3.80.0040.00818.43
8.3.70.0150.00616.73
8.3.60.0060.00916.38
8.3.50.0110.00616.53
8.3.40.0100.00718.84
8.3.30.0100.00718.71
8.3.20.0040.00421.81
8.3.10.0080.00023.48
8.3.00.0080.00019.68
8.2.290.0110.00920.57
8.2.280.0040.00418.44
8.2.270.0150.00417.04
8.2.260.0060.00320.02
8.2.250.0080.00017.02
8.2.240.0090.00619.14
8.2.230.0030.00620.94
8.2.220.0130.00637.54
8.2.210.0120.00326.77
8.2.200.0090.00018.43
8.2.190.0120.00316.60
8.2.180.0150.00016.38
8.2.170.0040.01118.84
8.2.160.0110.00422.96
8.2.150.0050.00224.18
8.2.140.0080.00024.66
8.2.130.0040.00420.35
8.2.120.0050.00326.35
8.2.110.0060.00322.20
8.2.100.0030.00917.78
8.2.90.0040.00420.47
8.2.80.0030.00619.25
8.2.70.0000.00918.03
8.2.60.0070.00318.16
8.2.50.0000.00818.10
8.2.40.0050.00318.16
8.2.30.0050.00218.19
8.2.20.0050.00218.06
8.2.10.0000.00717.81
8.2.00.0050.00218.04
8.1.330.0080.01116.73
8.1.320.0100.01116.11
8.1.310.0060.01218.69
8.1.300.0100.01020.13
8.1.290.0080.00330.84
8.1.280.0100.01025.92
8.1.270.0100.00723.95
8.1.260.0080.00026.35
8.1.250.0000.00828.09
8.1.240.0070.00322.61
8.1.230.0120.00021.03
8.1.220.0080.00317.79
8.1.210.0000.00918.82
8.1.200.0000.00817.35
8.1.190.0040.00417.23
8.1.180.0000.00818.10
8.1.170.0030.00618.90
8.1.160.0070.00018.89
8.1.150.0040.00419.02
8.1.140.0090.00017.71
8.1.130.0000.00718.89
8.1.120.0030.00317.47
8.1.110.0000.00817.38
8.1.100.0000.00917.48
8.1.90.0040.00417.46
8.1.80.0030.00717.38
8.1.70.0050.00317.45
8.1.60.0050.00317.59
8.1.50.0040.00417.42
8.1.40.0060.00317.40
8.1.30.0000.00817.56
8.1.20.0030.00617.50
8.1.10.0080.00017.61
8.1.00.0030.00517.54
8.0.300.0050.00220.04
8.0.290.0070.00016.63
8.0.280.0000.00718.36
8.0.270.0040.00416.73
8.0.260.0000.00616.83
8.0.250.0000.00916.94
8.0.240.0070.00016.94
8.0.230.0030.00316.94
8.0.220.0000.00916.87
8.0.210.0070.00016.77
8.0.200.0000.00716.96
8.0.190.0000.00716.95
8.0.180.0030.00516.96
8.0.170.0080.00016.84
8.0.160.0000.00716.93
8.0.150.0040.00416.80
8.0.140.0040.00416.87
8.0.130.0060.00313.32
8.0.120.0090.00016.82
8.0.110.0000.00716.81
8.0.100.0040.00416.97
8.0.90.0040.00416.82
8.0.80.0130.01016.86
8.0.70.0040.00416.94
8.0.60.0030.00516.77
8.0.50.0070.00016.89
8.0.30.0090.00917.11
8.0.20.0090.01217.40
8.0.10.0070.00016.96
8.0.00.0110.00916.90
7.4.330.0050.00015.55
7.4.320.0030.00316.49
7.4.300.0000.00616.66
7.4.290.0030.00316.65
7.4.280.0040.00416.60
7.4.270.0050.00316.61
7.4.260.0080.00016.50
7.4.250.0030.00316.40
7.4.240.0030.00316.41
7.4.230.0000.00716.27
7.4.220.0000.00816.36
7.4.210.0060.00716.61
7.4.200.0000.00716.70
7.4.160.0100.00616.51
7.4.140.0110.00817.86
7.4.130.0110.00716.52
7.4.120.0070.01316.50
7.4.110.0070.01016.58
7.4.100.0070.01716.41
7.4.90.0120.00616.25
7.4.80.0110.00719.39
7.4.70.0060.01216.47
7.4.60.0150.00316.53
7.4.50.0070.00716.41
7.4.40.0060.01516.66
7.4.00.0040.01415.22
7.3.330.0020.00213.21
7.3.320.0000.00613.23
7.3.310.0050.00216.45
7.3.300.0000.00716.30
7.3.290.0000.00616.32
7.3.280.0100.00716.32
7.3.260.0110.00916.55
7.3.240.0110.00816.55
7.3.230.0090.01216.32
7.3.210.0090.01716.42
7.3.200.0130.00616.36
7.3.190.0030.01316.60
7.3.180.0130.00916.66
7.3.170.0100.01316.55
7.3.160.0090.00616.57
7.2.330.0170.00316.75
7.2.320.0120.01216.50
7.2.310.0150.00916.91
7.2.300.0100.00716.79
7.2.290.0100.01616.56
7.2.60.0060.00916.94
7.2.30.0110.01517.70
7.2.20.0330.01217.64
7.2.10.0180.01217.59
7.2.00.0230.01417.93
7.1.200.0090.00315.92
7.1.150.0130.01016.71
7.1.140.0190.00616.54
7.1.130.0150.01516.38
7.1.120.0170.01416.35
7.1.110.0200.01415.95
7.1.100.0170.01416.16
7.1.90.0160.01315.61
7.1.80.0210.01416.34
7.1.70.0170.01315.46
7.1.60.0830.01733.00
7.1.50.0380.01332.91
7.1.40.0330.01632.41
7.1.30.0430.01332.70
7.1.20.0330.01732.66
7.1.10.0120.01514.83
7.1.00.0180.00814.80

preferences:
31.31 ms | 403 KiB | 5 Q