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', ]; for ( $i=0; $i<count($hotels); $i++ ) { $hotels[$i][4] = 0; } $starCoefOptions = range(0.1, 5, 0.1); $ratingCoefOptions = range(20, 10000, 20); $results = []; foreach ( $starCoefOptions as $starCoef ) { foreach ( $ratingCoefOptions as $ratingCoef ) { $topGenerated = buildTop($hotels, $starCoef, $ratingCoef); $topGenerated = array_slice($topGenerated, 0, count($top)); if ( $topGenerated === $top ) { $results[$starCoef][] = $ratingCoef; } } } foreach ( $results as $starCoef=>$ratingCoefs ) { echo $starCoef.': '.min($ratingCoefs).' - '.max($ratingCoefs)."\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.70.0130.10316.99
8.3.60.0070.10518.90
8.3.50.0180.11521.34
8.3.40.0130.10819.09
8.3.30.0100.10720.46
8.3.20.0070.05320.59
8.3.10.0070.05222.34
8.3.00.0000.05822.70
8.2.180.0000.11417.13
8.2.170.0030.10522.96
8.2.160.0070.10122.38
8.2.150.0000.05924.18
8.2.140.0030.05724.66
8.2.130.0030.05426.16
8.2.120.0030.05520.94
8.2.110.0070.10422.52
8.2.100.0030.09118.09
8.2.90.0030.08719.30
8.2.80.0100.07619.53
8.2.70.0070.08317.84
8.2.60.0060.09618.18
8.2.50.0030.08618.07
8.2.40.0030.08518.25
8.2.30.0030.08219.53
8.2.20.0100.09317.81
8.2.10.0070.08917.85
8.2.00.0070.08217.99
8.1.280.0100.11225.92
8.1.270.0060.05523.99
8.1.260.0070.05026.35
8.1.250.0100.04828.09
8.1.240.0030.10424.04
8.1.230.0030.11419.32
8.1.220.0000.09317.91
8.1.210.0070.08118.77
8.1.200.0100.08817.63
8.1.190.0000.09017.64
8.1.180.0030.08519.26
8.1.170.0000.08518.76
8.1.160.0070.09818.99
8.1.150.0070.08118.72
8.1.140.0070.08317.55
8.1.130.0070.08817.96
8.1.120.0030.08717.70
8.1.110.0000.09017.63
8.1.100.0030.09217.57
8.1.90.0000.08917.71
8.1.80.0030.08217.69
8.1.70.0000.09117.61
8.1.60.0070.10417.79
8.1.50.0000.11217.64
8.1.40.0030.10817.78
8.1.30.0030.10817.85
8.1.20.0070.10617.90
8.1.10.0030.10917.77
8.1.00.0000.12817.74
8.0.300.0070.08518.77
8.0.290.0030.08617.41
8.0.280.0030.08918.65
8.0.270.0000.09017.34
8.0.260.0070.08316.98
8.0.250.0070.07917.21
8.0.240.0030.08817.00
8.0.230.0030.08517.02
8.0.220.0030.08517.14
8.0.210.0030.08316.97
8.0.200.0000.08917.23
8.0.190.0070.10317.13
8.0.180.0000.10917.02
8.0.170.0030.11017.04
8.0.160.0000.10917.16
8.0.150.0030.10617.12
8.0.140.0000.12617.13
8.0.130.0000.11013.50
8.0.120.0000.11317.09
8.0.110.0030.10817.14
8.0.100.0030.10617.22
8.0.90.0030.11816.95
8.0.80.0030.14717.11
8.0.70.0030.10717.16
8.0.60.0070.10517.11
8.0.50.0030.10916.98
8.0.30.0080.15017.35
8.0.20.0160.14717.40
8.0.10.0000.11017.14
8.0.00.0110.20216.99
7.4.330.0000.08615.00
7.4.320.0000.08716.66
7.4.300.0070.08616.84
7.4.290.0060.10116.72
7.4.280.0000.12716.74
7.4.270.0030.10416.72
7.4.260.0000.10613.49
7.4.250.0030.11116.71
7.4.240.0020.10716.75
7.4.230.0030.10316.66
7.4.220.0130.27016.93
7.4.210.0100.14716.84
7.4.200.0000.10716.85
7.4.190.0030.10316.64
7.4.160.0070.14316.90
7.4.150.0100.16417.40
7.4.140.0130.14017.86
7.4.130.0100.16516.77
7.4.120.0170.18816.74
7.4.110.0060.16516.72
7.4.100.0060.15716.98
7.4.90.0070.17016.66
7.4.80.0070.15719.39
7.4.70.0100.13916.80
7.4.60.0130.14216.45
7.4.50.0000.09016.55
7.4.40.0070.16122.77
7.4.30.0120.14716.70
7.4.10.0100.17815.42
7.4.00.0100.19115.34
7.3.330.0000.10513.72
7.3.320.0070.11213.74
7.3.310.0030.10416.51
7.3.300.0000.10616.62
7.3.290.0130.17816.56
7.3.280.0100.17816.61
7.3.270.0030.15417.40
7.3.260.0070.15716.84
7.3.250.0100.17316.71
7.3.240.0140.16116.58
7.3.230.0130.14116.69
7.3.210.0060.18316.78
7.3.200.0100.16719.39
7.3.190.0130.17316.76
7.3.180.0070.15416.80
7.3.170.0060.17416.69
7.3.160.0130.17116.64
7.3.130.0030.23915.35
7.3.120.0090.18715.03
7.3.110.0070.19515.32
7.3.100.0000.17515.30
7.3.90.0030.19314.98
7.3.80.0050.19215.25
7.3.70.0030.16915.22
7.3.60.0050.17415.13
7.3.50.0070.19115.05
7.3.40.0070.17715.06
7.3.30.0070.16915.36
7.3.20.0070.17417.02
7.3.10.0100.18617.02
7.3.00.0030.17216.92
7.2.330.0000.15616.86
7.2.320.0090.16117.12
7.2.310.0100.17816.83
7.2.300.0120.18416.80
7.2.290.0100.15317.07
7.2.260.0070.23815.39
7.2.250.0050.24515.52
7.2.240.0070.19215.39
7.2.230.0080.19515.45
7.2.220.0070.16915.36
7.2.210.0100.16715.09
7.2.200.0050.19415.48
7.2.190.0030.18415.47
7.2.180.0050.22215.43
7.2.170.0030.20815.63
7.2.160.0070.23015.14
7.2.150.0000.18517.42
7.2.140.0030.19217.04
7.2.130.0070.17817.26
7.2.120.0120.16217.21
7.2.110.0130.19517.02
7.2.100.0300.16817.15
7.2.90.0070.18617.08
7.2.80.0170.18917.38
7.2.70.0110.18917.11
7.2.60.0070.16117.27
7.2.50.0160.16917.32
7.2.40.0100.16417.25
7.2.30.0070.19616.89
7.2.20.0080.20917.03
7.2.10.0110.18417.07
7.2.00.0060.16718.08
7.1.330.0070.26516.25
7.1.320.0050.25616.12
7.1.310.0120.28816.15
7.1.300.0030.29116.30
7.1.290.0020.27915.91
7.1.280.0030.28116.05
7.1.270.0020.31016.04
7.1.260.0020.25316.41
7.1.250.0030.29015.73
7.1.240.0030.34316.33
7.1.230.0070.26016.25
7.1.220.0070.27816.13
7.1.210.0070.27916.01
7.1.200.0120.18116.26
7.1.190.0030.29416.16
7.1.180.0070.31716.29
7.1.170.0000.30216.12
7.1.160.0030.26416.07
7.1.150.0030.28516.28
7.1.140.0000.28516.23
7.1.130.0000.29916.29
7.1.120.0100.27716.14
7.1.110.0000.30516.00
7.1.100.0020.20117.22
7.1.90.0100.25516.23
7.1.80.0070.31415.96
7.1.70.0050.18116.90
7.1.60.0100.21117.78
7.1.50.0050.21816.56
7.1.40.0030.32516.18
7.1.30.0000.24116.16
7.1.20.0070.25216.06
7.1.10.0070.30616.32
7.1.00.0080.27219.37
7.0.330.0030.35515.73
7.0.320.0070.35015.90
7.0.310.0110.25915.61
7.0.300.0000.35615.52
7.0.290.0030.35515.86
7.0.280.0100.28815.83
7.0.270.0030.26515.51
7.0.260.0070.27115.94
7.0.250.0100.32815.85
7.0.240.0030.29315.75
7.0.230.0070.32615.66
7.0.220.0030.30915.89
7.0.210.0070.28815.78
7.0.200.0080.23316.38
7.0.190.0030.33915.83
7.0.180.0000.36615.97
7.0.170.0030.32916.11
7.0.160.0000.28015.59
7.0.150.0070.33215.53
7.0.140.0050.27019.06
7.0.130.0070.28015.90
7.0.120.0070.33515.64
7.0.110.0070.32015.55
7.0.100.0070.24018.10
7.0.90.0120.27517.98
7.0.80.0070.23818.18
7.0.70.0080.25918.22
7.0.60.0070.25518.11
7.0.50.0050.27618.46
7.0.40.0080.29617.22
7.0.30.0050.25117.05
7.0.20.0080.23117.15
7.0.10.0130.24317.15
7.0.00.0070.27817.13
5.6.400.0070.65014.56
5.6.390.0000.63914.93
5.6.380.0070.58214.88
5.6.370.0030.69214.79
5.6.360.0030.64514.48
5.6.350.0130.55614.68
5.6.340.0030.69814.85
5.6.330.0030.61015.18
5.6.320.0030.60914.76
5.6.310.0070.64614.68
5.6.300.0000.65614.63
5.6.290.0030.56314.86
5.6.280.0050.49618.31
5.6.270.0070.69315.05
5.6.260.0070.67614.91
5.6.250.0020.47618.03
5.6.240.0080.48117.88
5.6.230.0050.49417.90
5.6.220.0080.45617.97
5.6.210.0070.46318.05
5.6.200.0070.52018.16
5.6.190.0130.50518.21
5.6.180.0070.47818.07
5.6.170.0070.49918.27
5.6.160.0080.51418.27
5.6.150.0030.54318.22
5.6.140.0030.54718.12
5.6.130.0120.53318.13
5.6.120.0130.43018.25
5.6.110.0030.48318.38
5.6.100.0070.51518.16
5.6.90.0120.52118.13
5.6.80.0020.49817.87
5.6.70.0080.53317.88
5.6.60.0070.51217.85
5.6.50.0030.54417.90
5.6.40.0100.53217.99
5.6.30.0030.52617.80
5.6.20.0070.52217.81
5.6.10.0100.50217.79
5.6.00.0030.45717.90
5.5.380.0100.53617.90
5.5.370.0080.51917.98
5.5.360.0100.54418.15
5.5.350.0100.52117.82
5.5.340.0080.50618.22
5.5.330.0100.52517.98
5.5.320.0050.52617.97
5.5.310.0050.48418.15
5.5.300.0050.55118.13
5.5.290.0020.55217.94
5.5.280.0020.48718.00
5.5.270.0050.45918.02
5.5.260.0070.48117.85
5.5.250.0130.54217.84
5.5.240.0120.49517.59
5.5.230.0080.54917.62
5.5.220.0070.54617.79
5.5.210.0050.56017.70
5.5.200.0070.51217.71
5.5.190.0070.53417.63
5.5.180.0070.53117.72
5.5.170.0000.69014.90
5.5.160.0020.47517.66
5.5.150.0050.48617.78
5.5.140.0050.54317.83
5.5.130.0070.50717.77
5.5.120.0050.52517.86
5.5.110.0080.51917.71
5.5.100.0100.53017.56
5.5.90.0050.53417.85
5.5.80.0100.53317.74
5.5.70.0030.55517.57
5.5.60.0050.53317.59
5.5.50.0050.54017.67
5.5.40.0070.48317.64
5.5.30.0050.51617.74
5.5.20.0070.50117.70
5.5.10.0020.52817.65
5.5.00.0050.55317.52
5.4.450.0080.48316.08
5.4.440.0080.55315.94
5.4.430.0070.54916.05
5.4.420.0050.55316.03
5.4.410.0020.50615.89
5.4.400.0080.47115.93
5.4.390.0080.53915.82
5.4.380.0120.54515.79
5.4.370.0000.48315.91
5.4.360.0030.54215.79
5.4.350.0050.47015.82
5.4.340.0030.50015.87
5.4.330.0000.62012.22
5.4.320.0030.50215.88
5.4.310.0020.56015.87
5.4.300.0000.47615.85
5.4.290.0020.48415.84
5.4.280.0020.52715.91
5.4.270.0080.52015.79
5.4.260.0050.49315.80
5.4.250.0070.45215.79
5.4.240.0030.54915.81
5.4.230.0050.50715.84
5.4.220.0100.55115.87
5.4.210.0000.54615.83
5.4.200.0080.49115.91
5.4.190.0050.55215.79
5.4.180.0020.57615.87
5.4.170.0080.50315.83
5.4.160.0100.46915.90
5.4.150.0120.54215.75
5.4.140.0030.53814.50
5.4.130.0100.49914.41
5.4.120.0050.53414.58
5.4.110.0070.51214.45
5.4.100.0050.49214.56
5.4.90.0050.49514.58
5.4.80.0100.49414.44
5.4.70.0050.49614.46
5.4.60.0100.54014.53
5.4.50.0070.47614.53
5.4.40.0350.46614.56
5.4.30.0020.49414.50
5.4.20.0050.47414.55
5.4.10.0050.44514.43
5.4.00.0080.43414.30
5.3.290.0000.03713.37
5.3.280.0030.04413.41
5.3.270.0070.02013.34
5.3.260.0090.03813.39
5.3.250.0050.03813.33
5.3.240.0070.04013.35
5.3.230.0050.03513.37
5.3.220.0000.04313.32
5.3.210.0030.03913.39
5.3.200.0020.02213.39
5.3.190.0050.03713.37
5.3.180.0020.04313.35
5.3.170.0030.04113.35
5.3.160.0100.03313.32
5.3.150.0000.03513.38
5.3.140.0050.03813.39
5.3.130.0020.02713.36
5.3.120.0050.02213.36
5.3.110.0040.02013.32
5.3.100.0020.02013.04
5.3.90.0030.01813.10
5.3.80.0040.02013.09
5.3.70.0020.02413.11
5.3.60.0050.01613.09
5.3.50.0050.02113.08
5.3.40.0010.02812.96
5.3.30.0010.02313.05
5.3.20.0020.03112.95
5.3.10.0050.03112.94
5.3.00.0030.03112.80
5.2.170.0030.02711.09
5.2.160.0030.06311.17
5.2.150.0030.06011.20
5.2.140.0000.03011.14
5.2.130.0000.05310.89
5.2.120.0000.03311.10
5.2.110.0030.02711.09
5.2.100.0030.05010.95
5.2.90.0000.04711.10
5.2.80.0100.02311.09
5.2.70.0030.03010.91
5.2.60.0030.02711.02
5.2.50.0070.06010.97
5.2.40.0000.03011.00
5.2.30.0000.05710.89
5.2.20.0030.03010.91
5.2.10.0000.03310.79
5.2.00.0030.02710.78
5.1.60.0030.02010.03
5.1.50.0030.03010.06
5.1.40.0070.0479.82
5.1.30.0070.04010.40
5.1.20.0000.06310.38
5.1.10.0100.01710.05
5.1.00.0000.02710.07
5.0.50.0000.0208.60
5.0.40.0000.0208.29
5.0.30.0000.0408.22
5.0.20.0000.0208.19
5.0.10.0000.0208.05
5.0.00.0030.0278.26
4.4.90.0030.0137.66
4.4.80.0070.0307.66
4.4.70.0070.0307.66
4.4.60.0000.0177.66
4.4.50.0000.0177.66
4.4.40.0000.0337.66
4.4.30.0030.0137.66
4.4.20.0030.0137.66
4.4.10.0000.0277.66
4.4.00.0000.0437.66
4.3.110.0000.0277.66
4.3.100.0000.0137.66
4.3.90.0030.0177.66
4.3.80.0000.0407.66
4.3.70.0030.0137.66
4.3.60.0000.0337.66
4.3.50.0000.0177.66
4.3.40.0030.0207.66
4.3.30.0000.0177.66
4.3.20.0030.0137.66
4.3.10.0030.0137.66
4.3.00.0000.0177.66

preferences:
67.56 ms | 401 KiB | 5 Q