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', ]; for ( $i=0; $i<count($hotels); $i++ ) { $hotels[$i][4] = 0; } $starCoefOptions = range(0.02, 3, 0.02); $ratingCoefOptions = range(100, 10000, 100); 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.0030.07318.56
8.3.50.0110.07721.21
8.3.40.0130.07318.89
8.3.30.0130.06220.42
8.3.20.0040.03620.61
8.3.10.0070.03121.27
8.3.00.0070.03322.77
8.2.180.0100.08016.63
8.2.170.0200.05322.96
8.2.160.0110.06020.43
8.2.150.0000.04024.18
8.2.140.0030.03824.66
8.2.130.0030.03426.16
8.2.120.0090.02821.30
8.2.110.0070.06319.34
8.2.100.0070.05518.03
8.2.90.0030.05819.33
8.2.80.0000.05718.18
8.2.70.0030.05917.63
8.2.60.0030.05318.05
8.2.50.0000.05718.07
8.2.40.0000.06018.59
8.2.30.0060.04919.66
8.2.20.0100.04617.93
8.2.10.0040.05317.83
8.2.00.0050.06717.82
8.1.280.0070.08425.92
8.1.270.0030.03723.99
8.1.260.0060.03226.35
8.1.250.0030.03428.09
8.1.240.0070.06422.31
8.1.230.0030.05221.09
8.1.220.0030.05418.77
8.1.210.0070.04819.34
8.1.200.0090.05817.63
8.1.190.0000.05617.78
8.1.180.0090.04918.10
8.1.170.0000.05518.76
8.1.160.0030.05419.04
8.1.150.0030.06718.90
8.1.140.0030.05317.64
8.1.130.0030.05217.92
8.1.120.0030.05317.58
8.1.110.0100.04717.67
8.1.100.0030.05717.64
8.1.90.0030.05217.63
8.1.80.0100.04917.66
8.1.70.0070.05417.63
8.1.60.0070.06317.84
8.1.50.0070.06717.64
8.1.40.0030.06817.76
8.1.30.0100.06417.86
8.1.20.0100.05917.86
8.1.10.0030.06517.74
8.1.00.0100.06217.59
8.0.300.0030.05220.03
8.0.290.0070.04917.30
8.0.280.0000.05718.58
8.0.270.0030.05317.34
8.0.260.0030.05316.97
8.0.250.0030.05517.10
8.0.240.0050.07317.14
8.0.230.0030.05317.07
8.0.220.0030.05517.09
8.0.210.0000.05517.13
8.0.200.0030.05317.16
8.0.190.0070.06317.14
8.0.180.0000.07017.03
8.0.170.0070.06417.11
8.0.160.0070.06217.08
8.0.150.0000.06917.03
8.0.140.0030.07116.93
8.0.130.0070.06013.52
8.0.120.0030.06717.07
8.0.110.0030.06617.01
8.0.100.0070.06217.13
8.0.90.0030.06617.12
8.0.80.0070.09017.05
8.0.70.0000.06917.09
8.0.60.0030.06716.95
8.0.50.0030.06617.15
8.0.30.0110.11517.40
8.0.20.0110.10117.40
8.0.10.0030.06617.04
8.0.00.0120.10216.93
7.4.330.0030.04816.82
7.4.320.0060.04916.82
7.4.300.0100.04516.82
7.4.290.0070.06016.78
7.4.280.0070.06016.72
7.4.270.0000.07016.79
7.4.260.0030.06413.50
7.4.250.0030.06716.70
7.4.240.0080.06116.76
7.4.230.0030.07216.70
7.4.220.0130.11016.75
7.4.210.0100.10016.83
7.4.200.0030.06516.91
7.4.190.0070.06216.99
7.4.160.0100.09216.82
7.4.150.0130.08217.40
7.4.140.0100.09217.86
7.4.130.0140.08716.73
7.4.120.0050.09416.77
7.4.110.0180.08616.66
7.4.100.0100.09216.64
7.4.90.0200.13616.72
7.4.80.0160.11019.39
7.4.70.0160.08816.76
7.4.60.0160.08516.80
7.4.50.0030.07016.58
7.4.40.0030.10422.77
7.4.30.0120.09116.81
7.4.00.0130.10515.33
7.3.330.0030.06513.45
7.3.320.0100.06613.61
7.3.310.0070.06516.66
7.3.300.0030.06516.61
7.3.290.0100.12616.55
7.3.280.0090.12316.59
7.3.270.0100.10317.40
7.3.260.0120.09618.24
7.3.250.0080.12616.54
7.3.240.0160.09216.66
7.3.230.0140.10416.60
7.3.210.0290.13416.58
7.3.200.0100.11619.39
7.3.190.0120.09716.65
7.3.180.0090.10316.89
7.3.170.0100.09216.59
7.3.160.0060.10016.71
7.3.120.0000.10415.02
7.2.330.0200.09917.15
7.2.320.0160.15717.15
7.2.310.0060.17516.96
7.2.300.0120.10216.68
7.2.290.0120.09317.12
7.2.60.0030.06417.01
7.2.00.0100.06019.68
7.1.200.0070.07016.18
7.1.100.0000.08118.48
7.1.70.0030.10417.61
7.1.60.0130.11219.17
7.1.50.0030.08817.01
7.1.00.0000.10322.71
7.0.200.0000.08317.16
7.0.140.0030.18722.31
7.0.110.0070.12020.45
7.0.100.0130.08720.54
7.0.90.0330.12320.21
7.0.80.0200.12720.40
7.0.70.0170.09320.33
7.0.60.0070.10720.40
7.0.50.0070.11720.30
7.0.40.0030.14020.28
7.0.30.0030.11720.06
7.0.20.0130.10320.28
7.0.10.0000.12720.07
7.0.00.0030.11319.98
5.6.280.0100.30021.46
5.6.260.0070.18321.09
5.6.250.0030.20721.09
5.6.240.0030.16321.10
5.6.230.0030.20321.10
5.6.220.0130.22721.06
5.6.210.0100.24021.11
5.6.200.0070.24721.17
5.6.190.0030.21721.19
5.6.180.0070.20721.07
5.6.170.0130.19721.20
5.6.160.0000.21321.09
5.6.150.0030.17021.17
5.6.140.0100.24021.05
5.6.130.0530.17321.09
5.6.120.0070.16021.02
5.6.110.0030.17021.08
5.6.100.0100.16021.03
5.6.90.0070.16720.93
5.6.80.0030.21720.53
5.6.70.0070.16720.40
5.6.60.0000.18720.63
5.6.50.0000.20720.66
5.6.40.0030.20720.23
5.6.30.0000.21720.45
5.6.20.0030.23320.54
5.6.10.0070.23720.50
5.6.00.0000.25020.22
5.5.380.0030.22318.08
5.5.370.0030.22018.07
5.5.360.0100.26317.86
5.5.350.0070.21718.11
5.5.340.0230.18318.43
5.5.330.0030.28718.46
5.5.320.0030.23018.27
5.5.310.0070.28318.51
5.5.300.0030.18318.38
5.5.290.0030.18318.49
5.5.280.0000.22018.34
5.5.270.0030.18018.42
5.5.260.0400.19318.42
5.5.250.0000.18018.36
5.5.240.0000.19017.91
5.5.230.0130.20717.90
5.5.220.0070.17317.93
5.5.210.0030.23017.73
5.5.200.0070.23717.90
5.5.190.0030.22017.87
5.5.180.0030.29317.77
5.5.160.0130.25717.78
5.5.150.0030.24317.80
5.5.140.0000.25317.78
5.5.130.0030.21717.91
5.5.120.0030.22017.91
5.5.110.0000.21317.77
5.5.100.0030.26017.81
5.5.90.0070.26317.71
5.5.80.0070.23017.80
5.5.70.0000.22717.72
5.5.60.0030.21717.59
5.5.50.0070.18717.61
5.5.40.0070.17717.71
5.5.30.0070.18017.57
5.5.20.0070.24717.78
5.5.10.0000.25717.60
5.5.00.0070.23017.62
5.4.450.0030.21719.93
5.4.440.0000.21019.93
5.4.430.0000.18019.79
5.4.420.0030.21719.80
5.4.410.0070.22319.77
5.4.400.0030.17319.70
5.4.390.0070.17319.60
5.4.380.0000.18719.48
5.4.370.0070.17719.70
5.4.360.0030.17319.48
5.4.350.0030.18319.54
5.4.340.0070.26719.34
5.4.320.0030.22019.60
5.4.310.0000.27019.69
5.4.300.0030.17719.48
5.4.290.0000.17719.42
5.4.280.0070.21019.34
5.4.270.0070.17719.32
5.4.260.0070.21319.45
5.4.250.0100.23719.59
5.4.240.0170.20719.32
5.4.230.0000.17719.54
5.4.220.0030.21319.43
5.4.210.0070.22019.48
5.4.200.0030.23019.50
5.4.190.0070.18019.34
5.4.180.0130.21319.61
5.4.170.0030.20719.58
5.4.160.0030.19719.61
5.4.150.0030.23319.43
5.4.140.0030.17716.80
5.4.130.0030.17716.85
5.4.120.0070.21316.74
5.4.110.0030.21016.90
5.4.100.0000.19016.88
5.4.90.0000.19016.94
5.4.80.0000.17716.89
5.4.70.0070.19016.71
5.4.60.0030.18316.90
5.4.50.0000.18016.79
5.4.40.0030.20316.90
5.4.30.0000.21016.80
5.4.20.0000.23017.01
5.4.10.0000.21016.70
5.4.00.0000.25316.27
5.3.290.0030.03714.55
5.3.280.0030.03314.62
5.3.270.0000.06014.55
5.3.260.0000.04014.51
5.3.250.0000.05014.46
5.3.240.0000.03314.39
5.3.230.0030.03014.46
5.3.220.0030.03014.64
5.3.210.0030.04014.63
5.3.200.0000.03314.63
5.3.190.0030.03314.63
5.3.180.0000.03314.49
5.3.170.0070.03014.35
5.3.160.0070.04014.47
5.3.150.0000.04314.44
5.3.140.0030.04714.58
5.3.130.0130.04714.57
5.3.120.0070.04314.55
5.3.110.0030.05714.45
5.3.100.0000.04313.89
5.3.90.0070.03313.97
5.3.80.0030.03713.80
5.3.70.0070.03313.96
5.3.60.0030.03713.96
5.3.50.0030.03713.87
5.3.40.0030.03013.91
5.3.30.0030.03313.75
5.3.20.0000.04013.72
5.3.10.0000.05313.59
5.3.00.0030.03313.57
5.2.170.0000.06712.38
5.2.160.0030.02312.38
5.2.150.0000.03012.38
5.2.140.0030.02712.38
5.2.130.0030.02712.38
5.2.120.0030.04712.38
5.2.110.0070.04012.38
5.2.100.0030.03712.38
5.2.90.0000.03012.38
5.2.80.0000.03012.38
5.2.70.0030.03712.38
5.2.60.0030.02712.38
5.2.50.0130.02012.38
5.2.40.0070.02712.38
5.2.30.0000.03012.38
5.2.20.0000.05712.38
5.2.10.0000.03312.38
5.2.00.0000.03312.38
5.1.60.0030.02312.38
5.1.50.0030.02712.38
5.1.40.0000.02712.38
5.1.30.0000.03012.38
5.1.20.0030.02012.38
5.1.10.0000.02712.38
5.1.00.0070.02312.38
5.0.50.0000.02312.38
5.0.40.0000.01712.38
5.0.30.0030.02712.38
5.0.20.0030.01712.38
5.0.10.0000.02012.38
5.0.00.0030.02312.38
4.4.90.0000.01312.38
4.4.80.0030.01012.38
4.4.70.0000.02312.38
4.4.60.0000.03012.38
4.4.50.0000.01712.38
4.4.40.0000.02312.38
4.4.30.0000.01712.38
4.4.20.0000.01712.38
4.4.10.0000.01312.38
4.4.00.0030.03012.38
4.3.110.0030.03012.38
4.3.100.0030.01312.38
4.3.90.0030.01712.38
4.3.80.0000.02312.38
4.3.70.0070.01012.38
4.3.60.0070.01012.38
4.3.50.0000.02012.38
4.3.40.0000.02012.38
4.3.30.0030.01312.38
4.3.20.0000.01712.38
4.3.10.0070.01012.38
4.3.00.0030.01312.38

preferences:
46.68 ms | 401 KiB | 5 Q