3v4l.org

run code in 300+ PHP versions simultaneously
<?php $hotels = [ ['Tsambika', 2, 8.1, 9122], ['Tivoli', 2, 8.1, 11403], ['Sant-Amon', 1, 9.0, 14661], ['Radian', 2, 8.4, 17267], ['Filmar', 2, 8.4, 18510], ['Mon', 2, 8.7, 19222], ]; $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.0060.01016.63
8.3.50.0100.00920.99
8.3.40.0070.00718.96
8.3.30.0110.00319.29
8.3.20.0000.00820.29
8.3.10.0080.00023.64
8.3.00.0090.00019.50
8.2.180.0040.01218.43
8.2.170.0070.00722.96
8.2.160.0070.00720.52
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0070.00026.16
8.2.120.0030.00619.48
8.2.110.0030.00722.20
8.2.100.0060.00617.97
8.2.90.0060.00317.75
8.2.80.0060.00317.97
8.2.70.0030.00618.16
8.2.60.0000.00818.05
8.2.50.0000.00919.35
8.2.40.0040.00422.37
8.2.30.0070.00018.18
8.2.20.0030.00517.74
8.2.10.0060.00318.22
8.2.00.0090.00017.89
8.1.280.0000.01525.92
8.1.270.0050.00322.14
8.1.260.0000.00826.35
8.1.250.0050.00328.09
8.1.240.0030.00624.05
8.1.230.0030.00919.14
8.1.220.0030.00617.77
8.1.210.0090.00018.77
8.1.200.0090.00317.38
8.1.190.0080.00017.35
8.1.180.0050.00318.10
8.1.170.0000.00818.56
8.1.160.0020.00522.12
8.1.150.0080.00018.79
8.1.140.0040.00417.60
8.1.130.0000.00817.88
8.1.120.0050.00217.59
8.1.110.0000.00717.39
8.1.100.0000.00817.57
8.1.90.0040.00417.57
8.1.80.0000.00717.44
8.1.70.0070.00017.50
8.1.60.0090.00017.67
8.1.50.0050.00317.52
8.1.40.0040.00417.61
8.1.30.0040.00417.57
8.1.20.0040.00417.65
8.1.10.0040.00417.55
8.1.00.0050.00317.50
8.0.300.0030.00621.99
8.0.290.0090.00016.88
8.0.280.0030.00318.49
8.0.270.0000.00817.30
8.0.260.0060.00017.22
8.0.250.0030.00317.07
8.0.240.0000.00717.10
8.0.230.0030.00517.08
8.0.220.0050.00217.07
8.0.210.0000.00816.96
8.0.200.0000.00717.07
8.0.190.0040.00417.08
8.0.180.0070.00016.97
8.0.170.0030.00516.91
8.0.160.0050.00316.81
8.0.150.0040.00417.01
8.0.140.0070.00016.89
8.0.130.0060.00013.46
8.0.120.0000.00816.98
8.0.110.0050.00217.02
8.0.100.0040.00416.83
8.0.90.0040.00416.89
8.0.80.0030.01616.92
8.0.70.0030.00517.03
8.0.60.0030.00516.80
8.0.50.0030.00617.05
8.0.30.0110.00817.08
8.0.20.0100.00917.42
8.0.10.0040.00417.10
8.0.00.0150.00716.80
7.4.330.0000.00515.00
7.4.320.0070.00016.61
7.4.300.0000.00716.66
7.4.290.0040.00416.70
7.4.280.0070.00016.60
7.4.270.0000.00716.72
7.4.260.0040.00416.68
7.4.250.0040.00416.57
7.4.240.0030.00316.71
7.4.230.0040.00416.36
7.4.220.0100.00916.73
7.4.210.0050.01016.77
7.4.200.0070.00016.63
7.4.190.0040.00416.58
7.4.160.0080.01016.78
7.4.150.0160.00617.40
7.4.140.0130.00517.86
7.4.130.0080.01016.58
7.4.120.0110.01116.64
7.4.110.0140.00716.69
7.4.100.0190.00016.59
7.4.90.0090.00916.73
7.4.80.0100.01319.39
7.4.70.0100.01316.61
7.4.60.0090.00916.73
7.4.50.0060.00316.60
7.4.40.0060.01022.77
7.4.30.0060.01116.64
7.4.00.0090.00614.79
7.3.330.0070.00013.49
7.3.320.0050.00013.54
7.3.310.0060.00316.49
7.3.300.0000.00716.51
7.3.290.0060.00816.43
7.3.280.0120.00616.42
7.3.270.0060.01217.40
7.3.260.0160.00716.71
7.3.250.0090.00916.40
7.3.240.0110.00716.73
7.3.230.0060.01216.49
7.3.210.0140.00316.54
7.3.200.0070.01519.39
7.3.190.0190.00216.73
7.3.180.0130.01016.45
7.3.170.0080.00816.64
7.3.160.0070.01016.42
7.3.120.0000.01314.75
7.2.330.0090.00916.56
7.2.320.0110.00816.71
7.2.310.0090.00916.89
7.2.300.0080.00916.82
7.2.290.0180.00016.69
7.2.00.0090.00319.39
7.1.100.0090.00318.09
7.1.70.0030.00617.17
7.1.60.0040.02119.33
7.1.50.0240.01034.89
7.1.00.0000.08322.43
7.0.200.0140.00715.01
7.0.140.0000.07322.04
7.0.60.0370.06720.12
7.0.50.0070.06718.00
7.0.40.0330.08320.02
7.0.30.0370.06320.16
7.0.20.0330.05020.18
7.0.10.0200.05720.40
7.0.00.0330.07720.26
5.6.280.0130.06720.91
5.6.210.0100.07320.48
5.6.200.0170.07718.16
5.6.190.0330.07720.52
5.6.180.0270.07720.54
5.6.170.0270.08320.55
5.6.160.0270.05020.67
5.6.150.0300.05720.48
5.6.140.0230.04720.41
5.6.130.0230.04320.29
5.6.120.0300.07720.48
5.6.110.0300.04720.33
5.6.100.0300.03720.17
5.6.90.0300.07320.39
5.6.80.0370.05019.73
5.6.70.0370.06019.84
5.6.60.0370.07019.71
5.6.50.0370.07319.73
5.6.40.0330.07319.70
5.6.30.0570.07719.54
5.6.20.0370.06719.76
5.6.10.0400.07019.75
5.6.00.0300.05319.75
5.5.350.0030.08320.46
5.5.340.0100.08017.94
5.5.330.0300.04720.27
5.5.320.0300.07720.28
5.5.310.0330.05020.32
5.5.300.0330.06720.21
5.5.290.0270.05319.93
5.5.280.0270.05320.20
5.5.270.0300.08020.32
5.5.260.0200.06320.00
5.5.250.0270.05319.77
5.5.240.0300.06019.59
5.5.230.0330.07719.35
5.5.220.0270.07719.65
5.5.210.0270.05019.35
5.5.200.0370.07019.55
5.5.190.0370.07019.45
5.5.180.0300.03719.63
5.5.160.0330.07319.62
5.5.150.0200.06319.56
5.5.140.0230.04319.69
5.5.130.0270.06319.49
5.5.120.0330.04319.57
5.5.110.0270.04719.31
5.5.100.0370.07019.24
5.5.90.0270.04319.49
5.5.80.0330.04019.39
5.5.70.0270.07319.21
5.5.60.0300.07319.56
5.5.50.0400.06319.21
5.5.40.0300.07019.50
5.5.30.0330.06719.53
5.5.20.0370.05319.52
5.5.10.0300.07719.43
5.5.00.0370.07319.43
5.4.450.0230.04719.46
5.4.440.0330.07719.49
5.4.430.0300.05719.25
5.4.420.0270.07019.48
5.4.410.0330.07019.36
5.4.400.0300.04719.09
5.4.390.0270.05719.25
5.4.380.0330.04719.25
5.4.370.0300.03719.21
5.4.360.0270.03719.18
5.4.350.0400.06319.14
5.4.340.0270.03718.88
5.4.320.0330.05719.18
5.4.310.0370.06719.21
5.4.300.0230.04319.04
5.4.290.0230.08019.21
5.4.280.0370.05319.24
5.4.270.0300.05319.10
5.4.260.0500.04019.14
5.4.250.0170.04719.14
5.4.240.0470.05319.03
5.4.230.0270.07319.14
5.4.220.0200.08319.25
5.4.210.0300.07019.24
5.4.200.0330.03719.15
5.4.190.0300.05019.23
5.4.180.0270.05019.14
5.4.170.0270.05719.13
5.4.160.0330.07019.19
5.4.150.0270.07018.83
5.4.140.0300.05716.42
5.4.130.0270.07316.45
5.4.120.0200.07316.39
5.4.110.0230.05016.46
5.4.100.0370.06316.46
5.4.90.0330.06716.40
5.4.80.0230.03716.48
5.4.70.0300.04016.40
5.4.60.0270.03316.34
5.4.50.0330.06316.34
5.4.40.0300.03016.29
5.4.30.0300.06016.47
5.4.20.0330.07016.45
5.4.10.0370.06016.43
5.4.00.0430.05715.86
5.3.290.0270.07714.64
5.3.280.0230.06314.38
5.3.270.0230.04714.54
5.3.260.0270.06014.62
5.3.250.0300.06714.70
5.3.240.0330.06014.55
5.3.230.0270.06014.57
5.3.220.0300.07014.50
5.3.210.0270.03714.49
5.3.200.0300.05714.49
5.3.190.0370.06314.52
5.3.180.0230.06314.44
5.3.170.0270.03314.51
5.3.160.0300.03714.46
5.3.150.0300.04014.50
5.3.140.0270.05014.49
5.3.130.0270.06314.49
5.3.120.0330.06714.37
5.3.110.0330.06714.52
5.3.100.0270.03713.95
5.3.90.0330.07014.11
5.3.80.0300.06713.83
5.3.70.0330.06313.94
5.3.60.0330.05713.93
5.3.50.0300.03713.76
5.3.40.0270.05313.88
5.3.30.0230.05013.86
5.3.20.0270.03713.51
5.3.10.0330.03713.60
5.3.00.0370.06013.58
5.2.170.0300.05012.86
5.2.160.0270.06012.86
5.2.150.0170.03312.86
5.2.140.0170.03712.86
5.2.130.0300.04012.86
5.2.120.0300.05312.86
5.2.110.0270.05312.86
5.2.100.0230.03712.86
5.2.90.0330.04312.86
5.2.80.0300.03012.86
5.2.70.0200.04312.86
5.2.60.0200.03012.86
5.2.50.0270.02312.86
5.2.40.0200.02712.86
5.2.30.0230.05312.86
5.2.20.0170.05312.86
5.2.10.0200.03712.86
5.2.00.0170.05012.86
5.1.60.0200.03712.86
5.1.50.0170.03312.86
5.1.40.0200.05012.86
5.1.30.0230.04712.86
5.1.20.0270.05012.86
5.1.10.0230.03712.86
5.1.00.0170.03312.86
5.0.50.0100.03712.86
5.0.40.0170.03012.86
5.0.30.0170.05012.86
5.0.20.0130.04012.86
5.0.10.0070.02712.86
5.0.00.0100.03012.86
4.4.90.0070.02012.86
4.4.80.0100.01312.86
4.4.70.0130.02712.86
4.4.60.0170.02012.86
4.4.50.0100.02012.86
4.4.40.0070.03012.86
4.4.30.0100.03312.86
4.4.20.0070.03712.86
4.4.10.0130.03312.86
4.4.00.0100.05012.86
4.3.110.0100.01712.86
4.3.100.0130.03312.86
4.3.90.0100.02012.86
4.3.80.0100.02312.86
4.3.70.0070.01712.86
4.3.60.0100.03712.86
4.3.50.0070.03012.86
4.3.40.0130.04712.86
4.3.30.0030.02712.86
4.3.20.0000.02012.86
4.3.10.0070.03312.86
4.3.00.0070.03312.86

preferences:
50.8 ms | 401 KiB | 5 Q