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, 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.0170.12018.52
8.3.50.0130.12021.27
8.3.40.0100.10018.97
8.3.30.0030.10820.45
8.3.20.0030.05520.44
8.3.10.0070.05321.17
8.3.00.0060.05822.51
8.2.180.0100.11418.41
8.2.170.0030.11122.96
8.2.160.0100.10022.15
8.2.150.0100.05124.18
8.2.140.0030.05624.66
8.2.130.0070.05226.16
8.2.120.0100.05420.94
8.2.110.0070.10519.63
8.2.100.0130.08217.78
8.2.90.0100.09219.47
8.2.80.0100.08518.18
8.2.70.0070.08617.75
8.2.60.0030.09018.29
8.2.50.0030.09018.07
8.2.40.0070.08318.40
8.2.30.0070.08019.66
8.2.20.0030.08917.91
8.2.10.0000.09417.98
8.2.00.0030.09117.93
8.1.280.0100.10825.92
8.1.270.0100.05123.99
8.1.260.0000.05926.35
8.1.250.0100.04928.09
8.1.240.0070.12322.70
8.1.230.0070.08621.11
8.1.220.0070.08618.77
8.1.210.0030.09119.20
8.1.200.0030.13617.61
8.1.190.0100.08117.55
8.1.180.0030.08618.10
8.1.170.0000.08718.84
8.1.160.0070.08219.21
8.1.150.0030.10618.86
8.1.140.0070.08417.68
8.1.130.0000.08517.99
8.1.120.0000.09117.58
8.1.110.0030.08917.56
8.1.100.0030.09217.63
8.1.90.0000.08917.60
8.1.80.0000.09017.67
8.1.70.0030.08717.66
8.1.60.0130.10317.76
8.1.50.0070.10517.81
8.1.40.0000.11417.75
8.1.30.0070.10617.68
8.1.20.0070.10617.79
8.1.10.0030.10917.77
8.1.00.0100.10317.79
8.0.300.0140.08520.12
8.0.290.0070.08517.29
8.0.280.0060.08418.70
8.0.270.0030.08817.41
8.0.260.0030.08616.88
8.0.250.0000.08717.18
8.0.240.0030.08817.10
8.0.230.0070.08317.13
8.0.220.0000.09017.16
8.0.210.0070.08217.09
8.0.200.0000.09017.24
8.0.190.0030.10917.07
8.0.180.0030.11117.11
8.0.170.0070.10717.01
8.0.160.0030.11017.22
8.0.150.0130.09817.11
8.0.140.0100.13616.91
8.0.130.0000.11613.52
8.0.120.0070.10817.00
8.0.110.0030.10917.06
8.0.100.0070.12517.11
8.0.90.0070.10817.05
8.0.80.0060.15217.12
8.0.70.0000.11617.17
8.0.60.0030.11017.14
8.0.50.0030.11017.14
8.0.30.0110.15817.31
8.0.20.0160.17017.40
8.0.10.0030.10917.18
8.0.00.0220.19517.00
7.4.330.0000.08316.82
7.4.320.0000.09316.80
7.4.300.0000.09616.73
7.4.290.0000.11116.68
7.4.280.0030.10716.86
7.4.270.0070.10316.74
7.4.260.0030.10513.50
7.4.250.0070.10516.70
7.4.240.0050.10916.82
7.4.230.0070.10916.91
7.4.220.0100.20716.88
7.4.210.0080.16616.79
7.4.200.0030.10716.85
7.4.190.0030.11016.66
7.4.160.0190.17116.80
7.4.150.0170.15417.40
7.4.140.0110.17017.86
7.4.130.0130.17916.70
7.4.120.0160.14716.72
7.4.110.0030.15116.76
7.4.100.0070.15816.84
7.4.90.0160.15516.66
7.4.80.0130.15719.39
7.4.70.0100.17416.79
7.4.60.0130.24416.71
7.4.50.0030.10016.58
7.4.40.0070.16222.77
7.4.30.0070.15316.76
7.4.00.0030.16915.61
7.3.330.0030.10513.46
7.3.320.0030.10513.64
7.3.310.0030.10716.46
7.3.300.0000.12016.65
7.3.290.0070.16216.67
7.3.280.0090.18116.59
7.3.270.0130.15617.40
7.3.260.0160.21918.24
7.3.250.0090.20516.76
7.3.240.0100.14716.79
7.3.230.0100.15016.72
7.3.210.0200.16816.65
7.3.200.0160.23419.39
7.3.190.0150.27316.68
7.3.180.0170.24916.94
7.3.170.0130.25216.82
7.3.160.0100.15016.88
7.3.120.0030.16715.15
7.2.330.0100.28216.79
7.2.320.0130.27816.95
7.2.310.0100.18617.20
7.2.300.0270.14716.75
7.2.290.0070.16516.99
7.2.00.0030.10719.45
7.1.100.0070.12718.13
7.1.70.0070.15117.54
7.1.60.0070.17219.17
7.1.50.0030.16817.37
7.1.00.0000.23322.66
7.0.200.0260.13915.10
7.0.140.0000.25022.62
7.0.100.0330.18320.48
7.0.90.0200.20720.37
7.0.80.0230.19020.36
7.0.70.0000.19020.40
7.0.60.0130.15320.31
7.0.50.0170.14720.59
7.0.40.0130.22320.54
7.0.30.0030.19020.51
7.0.20.0070.21020.49
7.0.10.0000.20320.59
7.0.00.0200.20020.45
5.6.280.0070.41721.34
5.6.250.0270.34321.23
5.6.240.0030.38721.16
5.6.230.0100.31320.98
5.6.220.0100.35721.09
5.6.210.0470.32321.16
5.6.200.0130.36721.50
5.6.190.0000.37321.54
5.6.180.0070.34721.55
5.6.170.0170.40721.47
5.6.160.0030.37021.43
5.6.150.0030.37021.50
5.6.140.0030.33321.64
5.6.130.0030.33321.53
5.6.120.0000.32321.54
5.6.110.0070.36021.50
5.6.100.0030.30321.41
5.6.90.0030.29321.57
5.6.80.0070.32720.94
5.6.70.0000.33721.02
5.6.60.0100.37320.84
5.6.50.0100.37020.94
5.6.40.0070.37720.91
5.6.30.0000.38020.78
5.6.20.0100.34320.88
5.6.10.0130.39020.82
5.6.00.0070.33720.81
5.5.380.0030.39320.95
5.5.370.0100.33720.95
5.5.360.0070.33320.88
5.5.350.0200.40020.87
5.5.340.0070.38321.30
5.5.330.0070.37321.29
5.5.320.0170.38321.28
5.5.310.0070.40721.27
5.5.300.0100.41321.33
5.5.290.0100.32321.30
5.5.280.0030.32721.38
5.5.270.0100.35321.37
5.5.260.0130.27721.29
5.5.250.0070.37721.08
5.5.240.0030.32020.68
5.5.230.0100.40320.67
5.5.220.0170.37720.70
5.5.210.0170.37320.62
5.5.200.0030.38720.47
5.5.190.0130.39020.46
5.5.180.0070.36020.73
5.5.160.0070.37720.71
5.5.150.0030.42020.64
5.5.140.0030.34320.56
5.5.130.0030.41020.59
5.5.120.0130.37320.59
5.5.110.0070.39720.68
5.5.100.0100.40720.57
5.5.90.0030.39020.56
5.5.80.0530.34320.52
5.5.70.0130.39720.41
5.5.60.0100.39720.57
5.5.50.0100.39320.70
5.5.40.0070.35720.50
5.5.30.0130.39320.69
5.5.20.0070.39020.50
5.5.10.0070.36020.55
5.5.00.0030.35320.56
5.4.450.0000.28019.80
5.4.440.0070.27319.84
5.4.430.0000.28719.93
5.4.420.0130.33319.79
5.4.410.0130.28019.69
5.4.400.0070.26719.46
5.4.390.0070.35719.56
5.4.380.0030.37319.49
5.4.370.0130.33319.53
5.4.360.0130.33019.46
5.4.350.0100.39019.61
5.4.340.0100.37719.38
5.4.320.0030.35719.51
5.4.310.0130.38719.36
5.4.300.0030.37719.41
5.4.290.0070.36719.52
5.4.280.0100.37719.42
5.4.270.0100.39719.55
5.4.260.0030.35719.45
5.4.250.0130.38319.45
5.4.240.0070.40019.52
5.4.230.0100.37019.36
5.4.220.0030.44019.61
5.4.210.0030.44019.36
5.4.200.0070.38719.45
5.4.190.0100.40719.55
5.4.180.0130.43019.50
5.4.170.0100.33719.39
5.4.160.0000.39019.29
5.4.150.0170.38019.30
5.4.140.0100.37316.82
5.4.130.0030.35716.85
5.4.120.0100.41016.97
5.4.110.0100.41016.77
5.4.100.0170.36316.81
5.4.90.0070.37716.95
5.4.80.0070.37316.66
5.4.70.0070.39016.88
5.4.60.0070.38716.62
5.4.50.0000.38316.64
5.4.40.0030.34716.92
5.4.30.0100.38016.82
5.4.20.0100.39716.86
5.4.10.0130.40316.75
5.4.00.0130.44716.30
5.3.290.0100.07714.67
5.3.280.0070.08314.59
5.3.270.0030.07014.47
5.3.260.0070.07714.54
5.3.250.0130.07314.57
5.3.240.0030.08014.62
5.3.230.0130.07314.56
5.3.220.0030.05314.51
5.3.210.0000.07314.56
5.3.200.0100.07014.39
5.3.190.0100.03314.43
5.3.180.0170.07014.53
5.3.170.0030.03314.48
5.3.160.0070.07314.56
5.3.150.0070.06714.52
5.3.140.0070.07314.55
5.3.130.0070.08014.54
5.3.120.0070.07314.39
5.3.110.0100.07314.41
5.3.100.0070.07014.02
5.3.90.0070.05013.89
5.3.80.0100.06014.01
5.3.70.0070.07713.97
5.3.60.0070.07314.00
5.3.50.0070.07013.86
5.3.40.0100.06713.90
5.3.30.0070.06713.93
5.3.20.0030.08013.63
5.3.10.0000.05313.41
5.3.00.0030.06313.62
5.2.170.0030.06712.17
5.2.160.0100.03012.17
5.2.150.0100.03712.17
5.2.140.0030.03712.17
5.2.130.0070.03712.17
5.2.120.0070.05712.17
5.2.110.0100.02712.17
5.2.100.0070.05012.17
5.2.90.0070.06012.17
5.2.80.0030.06312.17
5.2.70.0030.06312.17
5.2.60.0070.06012.17
5.2.50.0070.05712.17
5.2.40.0030.06012.17
5.2.30.0030.06312.17
5.2.20.0100.06312.17
5.2.10.0000.05712.17
5.2.00.0070.06012.17
5.1.60.0000.06012.17
5.1.50.0000.05712.17
5.1.40.0070.04312.17
5.1.30.0130.04312.17
5.1.20.0070.05312.17
5.1.10.0070.03012.17
5.1.00.0100.02312.17
5.0.50.0030.02312.17
5.0.40.0030.03012.17
5.0.30.0030.06012.17
5.0.20.0030.02312.17
5.0.10.0070.02712.17
5.0.00.0070.04012.17
4.4.90.0000.02012.17
4.4.80.0070.03012.17
4.4.70.0030.03012.17
4.4.60.0030.03312.17
4.4.50.0070.02712.17
4.4.40.0000.05712.17
4.4.30.0000.03312.17
4.4.20.0000.03712.17
4.4.10.0000.01712.17
4.4.00.0030.04712.17
4.3.110.0070.02712.17
4.3.100.0000.02012.17
4.3.90.0000.03012.17
4.3.80.0030.03712.17
4.3.70.0000.03712.17
4.3.60.0000.02312.17
4.3.50.0030.03712.17
4.3.40.0030.03312.17
4.3.30.0000.03712.17
4.3.20.0030.03312.17
4.3.10.0000.03712.17
4.3.00.0000.03312.17

preferences:
48.24 ms | 401 KiB | 5 Q