3v4l.org

run code in 300+ PHP versions simultaneously
<?php $hotels = [ ['Cala', 3, 8.7, 6000], ['Ocean', 3, 8.2, 6150], ['Orchid', 3, 8.0, 7200], ['Ya', 4, 8.3, 6950], ['Chaba', 3, 8.2, 7120], ]; $top = [ 'Cala', 'Ocean', 'Ya', 'Chaba', ]; for ( $i=0; $i<count($hotels); $i++ ) { $hotels[$i][4] = 0; } $starCoefOptions = range(0.1, 5, 0.1); $ratingCoefOptions = range(20, 10000, 20); foreach ( $starCoefOptions as $starCoef ) { foreach ( $ratingCoefOptions as $ratingCoef ) { $topGenerated = buildTop($hotels, $starCoef, $ratingCoef); $topGenerated = array_slice($topGenerated, 0, count($top)); if ( $topGenerated === $top ) { echo '$starCoef = '.$starCoef."\r\n"; echo '$ratingCoef = '.$ratingCoef."\r\n"; echo "\r\n"; } } } function buildTop($hotels, $starCoef, $ratingCoef) { for ( $i=0; $i<count($hotels); $i++ ) { for ( $j=$i+1; $j<count($hotels); $j++ ) { $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); if ( $price < $hotels[$j][3] ) { $hotels[$i][4]++; } else { $hotels[$j][4]++; } } } usort($hotels, function($hotelA, $hotelB){ return $hotelB[4]-$hotelA[4]; }); return array_map(function($hotel){ return $hotel[0]; }, $hotels); }

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.0130.11518.68
8.3.50.0070.12021.34
8.3.40.0100.12018.81
8.3.30.0070.10420.61
8.3.20.0060.05120.45
8.3.10.0030.05522.22
8.3.00.0070.05122.72
8.2.180.0070.10616.75
8.2.170.0160.09222.96
8.2.160.0130.09622.23
8.2.150.0100.04924.18
8.2.140.0000.06024.66
8.2.130.0030.05626.16
8.2.120.0070.05020.87
8.2.110.0070.10522.36
8.2.100.0130.08017.97
8.2.90.0070.08317.88
8.2.80.0100.09918.94
8.2.70.0030.08918.05
8.2.60.0040.08817.75
8.2.50.0070.08217.75
8.2.40.0000.08919.73
8.2.30.0030.08718.08
8.2.20.0030.08517.94
8.2.10.0030.08617.97
8.2.00.0070.08317.84
8.1.270.0070.05323.99
8.1.260.0030.05626.35
8.1.250.0070.05128.09
8.1.240.0000.10824.22
8.1.230.0070.08219.34
8.1.220.0000.09117.90
8.1.210.0030.08618.77
8.1.200.0030.08517.38
8.1.190.0030.08517.47
8.1.180.0100.07918.10
8.1.170.0030.08517.78
8.1.160.0000.08919.02
8.1.150.0030.08418.87
8.1.140.0070.08417.66
8.1.130.0000.10217.98
8.1.120.0100.09517.55
8.1.110.0030.08517.55
8.1.100.0030.09417.70
8.1.90.0000.08917.70
8.1.80.0070.08117.74
8.1.70.0000.09117.57
8.1.60.0030.10817.69
8.1.50.0000.11217.72
8.1.40.0070.12617.77
8.1.30.0070.10317.90
8.1.20.0070.10517.80
8.1.10.0030.10917.83
8.1.00.0030.10817.57
8.0.300.0070.08218.77
8.0.290.0000.09716.88
8.0.280.0000.08718.22
8.0.270.0070.08218.22
8.0.260.0030.08516.95
8.0.250.0030.08517.11
8.0.240.0070.08517.06
8.0.230.0000.09017.18
8.0.220.0030.08517.13
8.0.210.0000.08817.17
8.0.200.0030.08617.14
8.0.190.0030.10617.17
8.0.180.0030.11017.12
8.0.170.0070.10517.07
8.0.160.0030.10717.21
8.0.150.0070.10317.11
8.0.140.0030.12316.97
8.0.130.0070.10313.59
8.0.120.0000.11016.97
8.0.110.0030.10917.14
8.0.100.0070.10317.16
8.0.90.0070.10517.21
8.0.80.0070.15517.06
8.0.70.0000.11317.08
8.0.60.0030.10817.16
8.0.50.0000.11017.17
8.0.30.0180.19417.35
8.0.20.0150.15517.54
8.0.10.0070.11817.08
8.0.00.0140.16116.95
7.4.330.0070.07716.84
7.4.320.0000.08816.81
7.4.300.0030.08416.73
7.4.290.0030.10616.79
7.4.280.0000.10816.75
7.4.270.0070.10216.77
7.4.260.0030.10913.41
7.4.250.0000.11316.73
7.4.240.0020.10816.69
7.4.230.0000.11016.57
7.4.220.0190.17816.71
7.4.210.0090.15116.80
7.4.200.0030.10616.83
7.4.190.0030.10816.59
7.4.160.0080.14316.68
7.4.150.0170.13417.40
7.4.140.0200.13017.86
7.4.130.0110.15016.60
7.4.120.0140.14316.79
7.4.110.0030.15516.83
7.4.100.0100.15416.80
7.4.90.0130.15216.76
7.4.80.0100.19519.39
7.4.70.0070.14916.70
7.4.60.0060.15316.71
7.4.50.0000.10316.54
7.4.40.0000.16022.77
7.4.30.0180.13916.69
7.4.00.0070.16015.55
7.3.330.0030.10313.47
7.3.320.0000.10913.59
7.3.310.0100.09816.45
7.3.300.0070.10116.46
7.3.290.0030.18016.62
7.3.280.0090.16716.60
7.3.270.0140.16417.40
7.3.260.0140.15116.56
7.3.250.0130.17016.66
7.3.240.0260.23716.58
7.3.230.0200.14216.61
7.3.210.0220.25616.48
7.3.200.0160.26919.39
7.3.190.0090.15916.65
7.3.180.0130.15316.66
7.3.170.0150.14516.95
7.3.160.0230.22916.75
7.3.120.0070.16014.96
7.2.330.0220.15417.10
7.2.320.0100.16417.17
7.2.310.0130.16916.91
7.2.300.0130.16216.81
7.2.290.0190.14916.95
7.1.70.0100.13717.39
7.1.60.0030.12019.17
7.1.50.0130.17317.33
7.1.00.0100.23322.95
7.0.200.0030.15217.20
7.0.140.0100.24022.39
7.0.110.0170.21720.38
7.0.100.0130.22020.43
7.0.90.0070.18720.50
7.0.80.0070.13720.29
7.0.70.0000.21720.50
7.0.60.0070.20720.46
7.0.50.0030.21320.31
7.0.40.0130.20320.12
7.0.30.0030.17020.20
7.0.20.0130.22720.07
7.0.10.0100.19320.18
7.0.00.0030.20720.14
5.6.280.0070.41721.59
5.6.260.0100.35021.14
5.6.250.0070.42021.01
5.6.240.0130.36021.10
5.6.230.0130.37321.18
5.6.220.0070.30320.87
5.6.210.0070.30720.82
5.6.200.0170.37321.06
5.6.190.0030.35320.96
5.6.180.0030.38321.06
5.6.170.0170.36320.87
5.6.160.0100.35321.11
5.6.150.0030.35321.05
5.6.140.0030.32321.06
5.6.130.0100.35021.05
5.6.120.0130.37320.87
5.6.110.0070.36321.12
5.6.100.0030.38021.05
5.6.90.0000.38721.07
5.6.80.0100.35320.38
5.6.70.0130.33720.46
5.6.60.0030.25020.41
5.6.50.0100.33020.59
5.6.40.0100.31320.45
5.6.30.0070.30320.59
5.6.20.0300.25320.39
5.6.10.0000.32720.46
5.6.00.0000.34020.35
5.5.380.0100.31018.05
5.5.370.0100.38718.06
5.5.360.0000.37317.91
5.5.350.0130.38017.99
5.5.340.0030.37718.51
5.5.330.0030.40018.54
5.5.320.0070.36718.54
5.5.310.0030.38318.58
5.5.300.0130.35318.29
5.5.290.0000.39318.28
5.5.280.0000.37718.35
5.5.270.0130.39018.53
5.5.260.0030.38718.34
5.5.250.0030.40318.20
5.5.240.0070.39317.67
5.5.230.0070.38017.83
5.5.220.0070.31317.73
5.5.210.0070.36717.91
5.5.200.0070.35717.87
5.5.190.0030.38017.71
5.5.180.0070.35317.82
5.5.160.0170.30717.73
5.5.150.0030.32317.89
5.5.140.0030.38017.68
5.5.130.0070.32017.86
5.5.120.0130.38317.86
5.5.110.0430.31317.73
5.5.100.0130.37017.71
5.5.90.0070.37017.76
5.5.80.0030.37017.77
5.5.70.0070.37717.75
5.5.60.0030.40317.62
5.5.50.0130.37317.57
5.5.40.0100.37017.80
5.5.30.0000.38717.75
5.5.20.0030.37017.75
5.5.10.0000.40717.71
5.5.00.0130.38717.66
5.4.450.0130.39319.78
5.4.440.0070.34319.78
5.4.430.0070.37019.86
5.4.420.0030.36020.01
5.4.410.0070.37719.68
5.4.400.0100.35719.47
5.4.390.0070.38319.59
5.4.380.0030.32019.63
5.4.370.0000.32719.69
5.4.360.0100.38719.44
5.4.350.0000.32719.45
5.4.340.0070.32319.40
5.4.320.0030.26019.40
5.4.310.0000.32719.40
5.4.300.0100.36019.45
5.4.290.0070.39719.55
5.4.280.0070.37319.38
5.4.270.0100.36019.32
5.4.260.0100.35719.54
5.4.250.0070.35719.27
5.4.240.0070.36719.38
5.4.230.0030.41319.47
5.4.220.0030.38319.43
5.4.210.0000.37319.45
5.4.200.0070.39319.43
5.4.190.0030.37719.43
5.4.180.0100.37319.44
5.4.170.0130.37019.43
5.4.160.0070.38019.60
5.4.150.0070.37319.45
5.4.140.0030.37316.81
5.4.130.0100.40016.87
5.4.120.0130.36316.74
5.4.110.0030.38016.88
5.4.100.0100.38716.88
5.4.90.0100.38316.96
5.4.80.0100.37717.02
5.4.70.0100.40717.00
5.4.60.0030.38316.80
5.4.50.0070.38016.87
5.4.40.0070.38316.90
5.4.30.0130.36316.86
5.4.20.0100.37716.94
5.4.10.0100.39316.92
5.4.00.0070.39716.43
5.3.290.0000.03314.57
5.3.280.0070.07014.50
5.3.270.0170.06714.61
5.3.260.0100.08014.47
5.3.250.0030.07314.61
5.3.240.0030.07314.62
5.3.230.0070.03714.62
5.3.220.0070.07314.58
5.3.210.0070.07714.67
5.3.200.0000.08014.46
5.3.190.0030.08314.43
5.3.180.0030.08014.64
5.3.170.0130.06714.47
5.3.160.0030.03314.64
5.3.150.0070.07014.60
5.3.140.0070.07314.35
5.3.130.0100.07014.47
5.3.120.0100.07314.45
5.3.110.0030.08014.45
5.3.100.0030.08013.99
5.3.90.0070.07014.04
5.3.80.0100.07013.89
5.3.70.0070.07314.02
5.3.60.0100.07014.01
5.3.50.0070.07314.00
5.3.40.0070.07313.77
5.3.30.0200.05713.83
5.3.20.0070.06713.79
5.3.10.0100.06713.71
5.3.00.0070.08013.66
5.2.170.0030.06711.99
5.2.160.0070.05711.99
5.2.150.0070.05711.99
5.2.140.0070.03311.99
5.2.130.0000.04711.99
5.2.120.0130.05011.99
5.2.110.0070.06011.99
5.2.100.0070.06311.99
5.2.90.0030.04011.99
5.2.80.0030.03711.99
5.2.70.0030.05711.99
5.2.60.0070.06011.99
5.2.50.0030.06311.99
5.2.40.0100.05711.99
5.2.30.0070.06311.99
5.2.20.0030.06311.99
5.2.10.0100.05011.99
5.2.00.0030.06311.99
5.1.60.0030.04711.99
5.1.50.0070.05311.99
5.1.40.0030.05711.99
5.1.30.0070.05311.99
5.1.20.0100.05311.99
5.1.10.0070.04311.99
5.1.00.0000.03711.99
5.0.50.0070.04311.99
5.0.40.0030.03711.99
5.0.30.0000.07011.99
5.0.20.0070.04011.99
5.0.10.0070.04011.99
5.0.00.0030.07011.99
4.4.90.0000.03711.99
4.4.80.0070.03011.99
4.4.70.0030.03711.99
4.4.60.0100.03011.99
4.4.50.0070.03011.99
4.4.40.0030.03711.99
4.4.30.0030.03311.99
4.4.20.0070.03311.99
4.4.10.0000.04011.99
4.4.00.0070.05011.99
4.3.110.0000.04011.99
4.3.100.0000.02311.99
4.3.90.0070.03011.99
4.3.80.0070.05011.99
4.3.70.0030.03711.99
4.3.60.0130.02711.99
4.3.50.0000.03711.99
4.3.40.0030.05311.99
4.3.30.0000.03711.99
4.3.20.0070.02711.99
4.3.10.0070.03311.99
4.3.00.0000.03311.99

preferences:
55.32 ms | 400 KiB | 5 Q