3v4l.org

run code in 300+ PHP versions simultaneously
<?php $hotels = [ ['ibis', 2, 8.1, 11067], ['Loft', 0, 8.9, 12154], ['Green', 0, 9.1, 14114], ]; $totalHotelsNumber = 2; $starCoef = 0.2; $ratingCoef = 2000; for ( $i=0; $i<count($hotels); $i++ ) { $hotels[$i][4] = 0; } for ( $i=0; $i<count($hotels); $i++ ) { for ( $j=$i+1; $j<count($hotels); $j++ ) { echo 'Comparing '.$hotels[$i][0].' and '.$hotels[$j][0].'...'."\r\n"; $starDifference = $hotels[$i][1]-$hotels[$j][1]; $ratingToCompensate = $starDifference*$starCoef; $rating = $hotels[$i][2]+$ratingToCompensate; $ratingDifference = ($rating-$hotels[$j][2])*10; $priceToCompensate = $ratingDifference*$ratingCoef; $price = round($hotels[$i][3]-$priceToCompensate); echo $price.' VS '.$hotels[$j][3]."\r\n"; if ( $price < $hotels[$j][3] ) { echo $hotels[$i][0].' wins!'."\r\n"; $hotels[$i][4]++; } else { echo $hotels[$j][0].' wins!'."\r\n"; $hotels[$j][4]++; } echo "\r\n".'----------'."\r\n"; } } usort($hotels, function($hotelA, $hotelB){ return $hotelB[4]-$hotelA[4]; }); echo "\r\n".'----------'."\r\n"; echo 'Top:'."\r\n\r\n"; for ( $i=0; $i<count($hotels); $i++ ) { echo $hotels[$i][0].': '.$hotels[$i][4]."\r\n"; } echo "\r\n".'----------'."\r\n"; echo 'Finalists:'."\r\n\r\n"; for ( $i=0; $i<=1; $i++ ) { echo $hotels[$i][0]."\r\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.3.60.0090.00616.63
8.3.50.0080.01122.00
8.3.40.0140.00018.96
8.3.30.0070.00719.16
8.3.20.0040.00420.41
8.3.10.0040.00423.83
8.3.00.0050.00319.51
8.2.180.0090.00618.42
8.2.170.0150.00322.96
8.2.160.0100.00320.52
8.2.150.0030.00624.18
8.2.140.0080.00024.66
8.2.130.0000.00826.16
8.2.120.0070.00022.38
8.2.110.0040.00422.25
8.2.100.0070.00417.91
8.2.90.0000.00919.11
8.2.80.0030.00618.02
8.2.70.0030.00617.63
8.2.60.0050.00318.15
8.2.50.0000.00818.07
8.2.40.0040.00418.28
8.2.30.0040.00418.23
8.2.20.0080.00017.84
8.2.10.0030.00520.06
8.2.00.0050.00517.91
8.1.280.0110.00425.92
8.1.270.0000.00823.79
8.1.260.0000.00826.35
8.1.250.0080.00028.09
8.1.240.0030.00624.00
8.1.230.0080.00419.14
8.1.220.0040.00417.77
8.1.210.0080.00018.77
8.1.200.0060.00317.35
8.1.190.0060.00317.55
8.1.180.0000.00818.10
8.1.170.0070.00418.63
8.1.160.0070.00022.13
8.1.150.0040.00418.62
8.1.140.0000.00717.62
8.1.130.0040.00417.78
8.1.120.0050.00217.45
8.1.110.0040.00417.53
8.1.100.0040.00417.50
8.1.90.0070.00017.54
8.1.80.0000.00817.49
8.1.70.0030.00317.46
8.1.60.0040.00417.68
8.1.50.0000.00817.61
8.1.40.0000.00917.52
8.1.30.0040.00417.62
8.1.20.0000.00817.75
8.1.10.0030.00617.53
8.1.00.0030.00617.58
8.0.300.0000.00718.77
8.0.290.0070.00017.18
8.0.280.0070.00018.56
8.0.270.0000.00717.24
8.0.260.0060.00017.43
8.0.250.0070.00017.09
8.0.240.0070.00017.03
8.0.230.0040.00416.93
8.0.220.0050.00316.93
8.0.210.0030.00317.04
8.0.200.0040.00417.02
8.0.190.0080.00017.05
8.0.180.0000.00717.10
8.0.170.0080.00016.98
8.0.160.0040.00417.06
8.0.150.0030.00516.87
8.0.140.0040.00416.99
8.0.130.0000.00613.41
8.0.120.0040.00416.87
8.0.110.0000.00916.89
8.0.100.0040.00416.94
8.0.90.0000.00717.02
8.0.80.0090.00617.04
8.0.70.0050.00317.04
8.0.60.0040.00416.94
8.0.50.0000.00816.94
8.0.30.0140.00416.95
8.0.20.0150.00317.40
8.0.10.0050.00216.97
8.0.00.0050.01316.72
7.4.330.0000.00515.00
7.4.320.0000.00716.58
7.4.300.0070.00016.50
7.4.290.0030.00316.65
7.4.280.0040.00416.55
7.4.270.0050.00316.73
7.4.260.0000.00716.70
7.4.250.0040.00416.56
7.4.240.0050.00216.61
7.4.230.0070.00016.73
7.4.220.0070.01116.53
7.4.210.0070.00716.62
7.4.200.0040.00316.64
7.4.190.0050.00216.77
7.4.160.0080.00816.61
7.4.150.0120.00817.40
7.4.140.0110.01117.86
7.4.130.0120.00716.56
7.4.120.0080.00916.52
7.4.110.0090.00916.89
7.4.100.0090.00816.57
7.4.90.0140.00616.68
7.4.80.0060.01919.39
7.4.70.0100.00616.63
7.4.60.0090.00916.64
7.4.50.0040.00416.48
7.4.40.0060.00922.77
7.4.30.0030.01216.63
7.4.00.0070.01114.91
7.3.330.0000.00613.45
7.3.320.0030.00313.41
7.3.310.0040.00416.43
7.3.300.0000.00716.51
7.3.290.0060.00816.53
7.3.280.0040.01216.42
7.3.270.0090.00917.40
7.3.260.0060.01216.45
7.3.250.0110.00916.46
7.3.240.0120.00616.66
7.3.230.0110.00516.55
7.3.210.0040.01216.54
7.3.200.0120.01219.39
7.3.190.0140.00316.46
7.3.180.0080.00816.57
7.3.170.0100.00516.45
7.3.160.0100.00716.48
7.3.120.0070.01014.77
7.3.110.0100.01014.89
7.3.100.0060.00314.94
7.3.90.0060.00914.86
7.3.80.0100.00714.89
7.3.70.0100.00714.62
7.3.60.0100.00715.00
7.3.50.0080.00314.86
7.3.40.0040.00714.79
7.3.30.0070.01014.61
7.3.20.0000.01516.43
7.3.10.0000.01016.50
7.3.00.0040.01116.52
7.2.330.0080.00816.68
7.2.320.0100.00916.59
7.2.310.0170.00617.01
7.2.300.0120.00616.66
7.2.290.0130.01016.74
7.2.250.0070.01315.28
7.2.240.0060.01315.30
7.2.230.0000.01014.93
7.2.220.0100.00615.12
7.2.210.0040.01515.23
7.2.200.0060.01015.13
7.2.190.0070.00715.15
7.2.180.0080.00815.13
7.2.170.0070.00715.05
7.2.60.0100.00316.97
7.2.50.0130.00717.14
7.1.330.0000.01516.02
7.1.320.0070.00715.90
7.1.310.0030.01215.73
7.1.300.0070.00715.99
7.1.290.0070.00715.79
7.1.280.0100.00715.76
7.1.270.0090.00615.81
7.1.260.0000.01215.94
7.1.200.0070.00715.63
7.1.100.0060.00617.70
7.1.70.0040.00816.87
7.1.60.0040.02219.33
7.1.50.0250.01134.82
7.1.00.0100.07022.45
7.0.200.0170.00314.95
7.0.140.0030.06721.95
7.0.60.0200.08720.12
7.0.50.0070.08017.99
7.0.40.0100.03720.40
7.0.30.0400.04720.13
7.0.20.0370.07320.19
7.0.10.0070.09020.25
7.0.00.0130.08320.32
5.6.280.0030.07320.95
5.6.210.0130.07720.71
5.6.200.0070.05718.25
5.6.190.0000.05720.47
5.6.180.0170.06020.77
5.6.170.0270.08020.62
5.6.160.0030.04720.48
5.6.150.0070.04718.18
5.6.140.0000.05718.14
5.6.130.0070.03718.17
5.6.120.0030.08321.13
5.6.110.0030.08721.02
5.6.100.0130.06020.98
5.6.90.0100.07720.96
5.6.80.0030.09320.40
5.5.350.0070.04320.32
5.5.340.0000.09017.94
5.5.330.0100.07020.29
5.5.320.0230.04320.41
5.5.310.0230.03720.51
5.5.300.0000.04318.00
5.5.290.0170.05317.93
5.5.280.0030.04720.90
5.5.270.0100.05720.75
5.5.260.0030.08720.91
5.5.250.0100.03320.60
5.5.240.0270.07320.09
5.4.450.0330.03719.57
5.4.440.0270.07719.29
5.4.430.0200.03719.54
5.4.420.0170.08019.38
5.4.410.0270.07019.28
5.4.400.0170.03718.97
5.4.390.0130.05018.82
5.4.380.0230.04318.83
5.4.370.0270.06319.28
5.4.360.0230.04319.28
5.4.350.0100.05019.15
5.4.340.0230.05319.06
5.4.320.0170.08319.07
5.4.310.0330.04019.05
5.4.300.0170.08019.05
5.4.290.0100.06018.94
5.4.280.0130.04018.87
5.4.270.0200.07019.13
5.4.260.0270.07019.13
5.4.250.0200.03719.25
5.4.240.0170.05019.24
5.4.230.0170.04718.94
5.4.220.0270.07019.21
5.4.210.0330.06719.08
5.4.200.0200.04319.23
5.4.190.0270.07319.08
5.4.180.0270.07319.12
5.4.170.0170.06019.07
5.4.160.0200.06319.19
5.4.150.0300.06719.03
5.4.140.0230.07016.68
5.4.130.0170.07316.52
5.4.120.0300.06316.56
5.4.110.0200.04716.46
5.4.100.0200.07316.63
5.4.90.0230.06716.46
5.4.80.0300.06716.24
5.4.70.0370.06016.43
5.4.60.0270.04016.54
5.4.50.0400.05716.23
5.4.40.0230.05716.26
5.4.30.0330.06016.61
5.4.20.0230.06016.63
5.4.10.0170.07716.52
5.4.00.0330.05315.89
5.3.290.0200.06714.52
5.3.280.0300.06314.55
5.3.270.0230.04714.63
5.3.260.0230.05714.51
5.3.250.0200.05714.63
5.3.240.0270.06314.48
5.3.230.0300.03714.43
5.3.220.0230.06314.41
5.3.210.0270.07014.55
5.3.200.0230.07014.66
5.3.190.0300.04314.66
5.3.180.0330.04714.40
5.3.170.0230.06714.67
5.3.160.0230.07014.50
5.3.150.0270.07014.51
5.3.140.0330.06314.43
5.3.130.0270.06714.60
5.3.120.0270.07314.50
5.3.110.0200.04314.57
5.3.100.0330.06313.88
5.3.90.0270.05313.88
5.3.80.0170.07313.96
5.3.70.0230.06313.95
5.3.60.0170.04013.95
5.3.50.0170.04713.91
5.3.40.0270.02713.89
5.3.30.0200.03713.81
5.3.20.0230.03313.55
5.3.10.0300.06013.61
5.3.00.0200.05013.43
5.2.170.0170.03011.96
5.2.160.0200.04011.96
5.2.150.0200.03711.96
5.2.140.0100.04711.96
5.2.130.0100.03711.96
5.2.120.0170.03011.96
5.2.110.0270.05011.96
5.2.100.0170.03011.96
5.2.90.0170.03711.96
5.2.80.0170.02711.96
5.2.70.0230.05711.96
5.2.60.0170.05011.96
5.2.50.0270.05011.96
5.2.40.0100.05011.96
5.2.30.0130.05011.96
5.2.20.0130.06011.96
5.2.10.0070.06011.96
5.2.00.0200.04711.96
5.1.60.0170.03711.96
5.1.50.0200.03011.96
5.1.40.0200.04711.96
5.1.30.0170.05711.96
5.1.20.0230.04011.96
5.1.10.0170.05311.96
5.1.00.0130.04711.96
5.0.50.0070.04311.96
5.0.40.0100.03311.96
5.0.30.0070.06711.96
5.0.20.0170.03011.96
5.0.10.0070.02711.96
5.0.00.0070.04711.96
4.4.90.0070.02711.96
4.4.80.0130.01711.96
4.4.70.0100.03311.96
4.4.60.0100.03011.96
4.4.50.0030.03311.96
4.4.40.0070.05011.96
4.4.30.0130.03311.96
4.4.20.0070.03711.96
4.4.10.0070.03711.96
4.4.00.0100.05311.96
4.3.110.0070.03011.96
4.3.100.0070.03711.96
4.3.90.0070.02711.96
4.3.80.0130.05011.96
4.3.70.0100.03311.96
4.3.60.0070.03311.96
4.3.50.0070.03311.96
4.3.40.0070.04711.96
4.3.30.0000.02011.96
4.3.20.0070.01711.96
4.3.10.0030.02311.96
4.3.00.0070.03311.96

preferences:
34.71 ms | 401 KiB | 5 Q