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 = [ 'Ocean', 'Ya', 'Chaba', ]; for ( $i=0; $i<count($hotels); $i++ ) { $hotels[$i][4] = 0; } $starCoefOptions = range(0.02, 5, 0.02); $ratingCoefOptions = range(50, 10000, 50); 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.40.0070.20218.88
8.3.30.0130.25819.04
8.3.20.0070.10119.03
8.3.10.0070.10221.35
8.3.00.0000.11423.73
8.2.170.0070.22822.96
8.2.160.0130.19420.66
8.2.150.0030.10524.18
8.2.140.0030.10324.66
8.2.130.0060.10026.16
8.2.120.0000.10621.30
8.2.110.0070.20620.48
8.2.100.0070.16518.03
8.2.90.0000.17119.65
8.2.80.0070.16318.18
8.2.70.0070.16317.63
8.2.60.0070.16718.05
8.2.50.0070.16518.07
8.2.40.0030.16918.45
8.2.30.0030.15621.39
8.2.20.0000.16917.89
8.2.10.0030.16617.84
8.2.00.0030.17017.96
8.1.270.0030.10423.99
8.1.260.0070.13026.35
8.1.250.0070.09628.09
8.1.240.0000.20522.72
8.1.230.0130.15421.15
8.1.220.0030.17118.77
8.1.210.0070.15219.03
8.1.200.0100.18917.61
8.1.190.0100.15817.76
8.1.180.0030.16318.10
8.1.170.0030.15918.90
8.1.160.0100.16019.11
8.1.150.0030.16418.76
8.1.140.0070.16417.55
8.1.130.0000.15918.04
8.1.120.0100.19517.58
8.1.110.0100.15717.58
8.1.100.0000.18017.66
8.1.90.0030.16417.66
8.1.80.0100.15417.59
8.1.70.0000.16817.70
8.1.60.0000.21217.79
8.1.50.0030.20817.58
8.1.40.0000.21317.73
8.1.30.0030.20817.70
8.1.20.0030.20817.83
8.1.10.0000.21417.82
8.1.00.0030.21017.61
8.0.300.0000.16519.97
8.0.290.0000.16717.30
8.0.280.0000.16618.54
8.0.270.0030.16817.48
8.0.260.0030.16417.10
8.0.250.0070.16017.14
8.0.240.0100.16017.15
8.0.230.0030.16417.07
8.0.220.0030.16517.15
8.0.210.0000.16517.07
8.0.200.0000.17517.12
8.0.190.0000.21217.16
8.0.180.0070.20617.04
8.0.170.0070.20717.19
8.0.160.0070.20517.10
8.0.150.0070.20717.01
8.0.140.0030.20816.98
8.0.130.0000.21013.49
8.0.120.0070.20617.05
8.0.110.0070.20917.16
8.0.100.0000.21717.09
8.0.90.0030.21017.00
8.0.80.0160.27117.06
8.0.70.0000.24017.08
8.0.60.0070.20816.94
8.0.50.0000.21417.09
8.0.30.0100.28717.37
8.0.20.0110.30717.49
8.0.10.0000.21217.23
8.0.00.0170.32317.00
7.4.330.0070.16314.88
7.4.320.0070.16216.73
7.4.300.0030.16316.70
7.4.290.0000.20616.80
7.4.280.0070.20416.62
7.4.270.0000.21116.80
7.4.260.0030.20713.41
7.4.250.0030.20616.80
7.4.240.0030.20616.84
7.4.230.0000.20816.72
7.4.220.0130.28616.66
7.4.210.0070.33716.75
7.4.200.0000.20716.61
7.4.190.0030.20516.95
7.4.160.0070.27116.65
7.4.150.0130.27117.40
7.4.140.0080.28917.86
7.4.130.0100.35616.81
7.4.120.0160.32016.69
7.4.110.0100.29016.76
7.4.100.0130.32016.95
7.4.90.0100.30616.78
7.4.80.0130.29519.39
7.4.70.0130.29116.52
7.4.60.0170.26816.79
7.4.50.0070.18516.57
7.4.40.0030.31322.52
7.4.30.0160.30016.66
7.4.00.0100.30515.48
7.3.330.0000.20613.59
7.3.320.0030.20413.61
7.3.310.0070.20516.46
7.3.300.0030.20716.70
7.3.290.0100.29716.62
7.3.280.0120.32816.61
7.3.270.0100.28517.40
7.3.260.0130.31918.24
7.3.250.0110.29616.65
7.3.240.0100.32316.69
7.3.230.0190.26516.58
7.3.210.0130.33216.81
7.3.200.0160.31119.39
7.3.190.0070.35616.65
7.3.180.0160.34016.54
7.3.170.0030.33916.85
7.3.160.0070.26616.69
7.3.120.0070.29415.53
7.2.330.0100.29616.97
7.2.320.0100.40717.04
7.2.310.0130.50916.82
7.2.300.0030.34017.03
7.2.290.0200.48916.80
7.2.00.0100.21119.70
7.1.200.0070.24216.31
7.1.100.0070.25618.40
7.1.70.0070.22017.59
7.1.60.0100.25319.40
7.1.50.0100.21217.33
7.1.00.0000.26022.82
7.0.200.0030.25217.13
7.0.140.0030.37022.31
7.0.60.0070.33720.29
7.0.50.0070.29718.37
7.0.40.0070.26720.47
7.0.30.0270.27020.38
7.0.20.0230.28720.46
7.0.10.0300.25320.62
7.0.00.0000.27720.47
5.6.280.0070.71321.57
5.6.210.0070.64020.91
5.6.200.0200.61318.67
5.6.190.0130.61320.82
5.6.180.0330.59720.77
5.6.170.0230.62720.79
5.6.160.0070.66320.88
5.6.150.0070.57318.70
5.6.140.0000.59318.64
5.6.130.0030.85018.60
5.6.120.0100.63721.49
5.6.110.0170.63021.36
5.6.100.0100.56721.52
5.6.90.0200.63021.43
5.6.80.0030.66320.85
5.6.70.4100.58720.89
5.5.350.0230.68720.92
5.5.340.0070.67718.50
5.5.330.0070.62020.71
5.5.320.0170.66720.73
5.5.310.0270.65320.82
5.5.300.0030.69018.32
5.5.290.0000.64718.41
5.5.280.1870.60321.22
5.5.270.0100.67721.27
5.5.260.0070.68321.33
5.5.250.0130.66721.07
5.5.240.0100.68320.63
5.4.450.0400.62019.76
5.4.440.0230.63019.68
5.4.430.0200.65320.04
5.4.420.0070.60719.75
5.4.410.0200.67019.75
5.4.400.0100.59719.34
5.4.390.0270.65319.43
5.4.380.0270.63319.26
5.4.370.0230.64319.47
5.4.360.0200.65019.57
5.4.350.0170.68019.56
5.4.340.0100.68319.42
5.4.320.0270.64719.26
5.4.310.0230.65319.40
5.4.300.0130.58719.22
5.4.290.0170.68019.63
5.4.280.0230.63319.40
5.4.270.0330.68719.41
5.4.260.0130.58319.42
5.4.250.0200.65019.53
5.4.240.0130.66019.41
5.4.230.0130.62019.71
5.4.220.0070.59019.63
5.4.210.0200.69719.59
5.4.200.0100.61719.41
5.4.190.0270.63719.54
5.4.180.0230.65719.25
5.4.170.0270.65019.70
5.4.160.0200.64719.20
5.4.150.0170.63719.54
5.4.140.0270.66016.71
5.4.130.0230.75716.77
5.4.120.0130.67316.72
5.4.110.0400.68717.00
5.4.100.0200.65717.00
5.4.90.0200.65316.75
5.4.80.0200.65716.76
5.4.70.0200.68716.92
5.4.60.0200.65716.63
5.4.50.0300.64316.76
5.4.40.0400.64016.98
5.4.30.0200.61316.88
5.4.20.0330.62716.71
5.4.10.0300.64016.75
5.4.00.0230.66716.17
5.3.290.0230.06314.63
5.3.280.0170.04014.62
5.3.270.0230.04714.58
5.3.260.0230.03714.72
5.3.250.0230.07014.59
5.3.240.0200.06714.54
5.3.230.0270.06714.53
5.3.220.0130.08014.60
5.3.210.0270.04014.47
5.3.200.0270.06714.55
5.3.190.0230.07014.42
5.3.180.0370.05314.47
5.3.170.0270.06714.44
5.3.160.0200.07314.52
5.3.150.0200.07714.40
5.3.140.0200.07014.59
5.3.130.0200.06714.50
5.3.120.0230.06714.52
5.3.110.0230.04714.38
5.3.100.0170.08013.99
5.3.90.0230.07313.87
5.3.80.0230.07313.86
5.3.70.0230.05313.81
5.3.60.0230.06713.88
5.3.50.0270.06013.89
5.3.40.0330.03013.99
5.3.30.0200.06013.70
5.3.20.0230.06713.59
5.3.10.0230.06713.75
5.3.00.0230.06013.59
5.2.170.0230.05312.42
5.2.160.0170.04012.42
5.2.150.0270.05312.42
5.2.140.0230.05312.42
5.2.130.0200.04012.42
5.2.120.0130.04012.42
5.2.110.0170.04712.42
5.2.100.0170.05712.42
5.2.90.0200.05712.42
5.2.80.0200.04312.42
5.2.70.0330.04712.42
5.2.60.0300.05012.42
5.2.50.0200.03312.42
5.2.40.0100.03312.42
5.2.30.0130.04712.42
5.2.20.0170.05712.42
5.2.10.0170.06012.42
5.2.00.0230.04712.42
5.1.60.0170.05012.42
5.1.50.0170.04312.42
5.1.40.0070.03312.42
5.1.30.0170.05312.42
5.1.20.0100.06312.42
5.1.10.0170.04312.42
5.1.00.0170.04712.42
5.0.50.0070.05012.42
5.0.40.0070.02012.42
5.0.30.0070.06312.42
5.0.20.0130.04012.42
5.0.10.0130.03712.42
5.0.00.0130.05712.42
4.4.90.0070.03712.42
4.4.80.0130.02712.42
4.4.70.0170.02312.42
4.4.60.0070.02312.42
4.4.50.0100.03312.42
4.4.40.0100.04312.42
4.4.30.0170.03012.42
4.4.20.0070.04012.42
4.4.10.0130.02712.42
4.4.00.0070.03712.42
4.3.110.0130.02312.42
4.3.100.0070.02012.42
4.3.90.0030.03712.42
4.3.80.0130.04012.42
4.3.70.0030.03012.42
4.3.60.0170.02312.42
4.3.50.0100.03312.42
4.3.40.0070.05312.42
4.3.30.0030.03312.42
4.3.20.0030.03012.42
4.3.10.0070.02712.42
4.3.00.0030.02312.42

preferences:
37.8 ms | 400 KiB | 5 Q