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 = [ 'Ya', 'Ocean', 'Cala', ]; 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.60.0230.21218.63
8.3.50.0130.20721.27
8.3.40.0100.19819.06
8.3.30.0070.19718.96
8.3.20.0030.10418.86
8.3.10.0030.10521.39
8.3.00.0100.10822.02
8.2.180.0030.22416.88
8.2.170.0130.21522.96
8.2.160.0100.18520.50
8.2.150.0000.10824.18
8.2.140.0030.10724.66
8.2.130.0030.10326.16
8.2.120.0070.10121.19
8.2.110.0070.20619.57
8.2.100.0070.17017.97
8.2.90.0030.20719.25
8.2.80.0030.17117.97
8.2.70.0070.16617.88
8.2.60.0070.16318.05
8.2.50.0030.18518.07
8.2.40.0030.17818.59
8.2.30.0000.15919.70
8.2.20.0000.16817.86
8.2.10.0070.16518.09
8.2.00.0070.18217.99
8.1.280.0070.20825.92
8.1.270.0030.10223.99
8.1.260.0070.09826.35
8.1.250.0060.09728.09
8.1.240.0070.19924.17
8.1.230.0130.19317.57
8.1.220.0030.17017.91
8.1.210.0070.16318.77
8.1.200.0070.16117.61
8.1.190.0030.18517.60
8.1.180.0030.16418.10
8.1.170.0030.15818.84
8.1.160.0030.16219.10
8.1.150.0030.16618.73
8.1.140.0030.16617.55
8.1.130.0030.15617.96
8.1.120.0060.16217.59
8.1.110.0030.16517.71
8.1.100.0100.16817.61
8.1.90.0030.16817.66
8.1.80.0030.16117.66
8.1.70.0070.16117.57
8.1.60.0070.20617.77
8.1.50.0000.21317.58
8.1.40.0000.21317.60
8.1.30.0000.21317.90
8.1.20.0030.21117.71
8.1.10.0070.20317.80
8.1.00.0100.20417.71
8.0.300.0030.16018.77
8.0.290.0100.16316.88
8.0.280.0000.16818.66
8.0.270.0070.16317.47
8.0.260.0070.16216.98
8.0.250.0030.16817.13
8.0.240.0000.16917.15
8.0.230.0070.16517.07
8.0.220.0030.16816.99
8.0.210.0030.16517.09
8.0.200.0030.16717.13
8.0.190.0000.21217.17
8.0.180.0070.20917.02
8.0.170.0070.21217.13
8.0.160.0000.21217.01
8.0.150.0030.21017.11
8.0.140.0070.20517.09
8.0.130.0070.20513.58
8.0.120.0070.20716.95
8.0.110.0000.21317.12
8.0.100.0000.21217.17
8.0.90.0070.20817.05
8.0.80.0160.29517.07
8.0.70.0030.20816.98
8.0.60.0000.21717.23
8.0.50.0030.21117.22
8.0.30.0150.29017.27
8.0.20.0100.32217.40
8.0.10.0000.22217.21
8.0.00.0080.33117.12
7.4.330.0030.15617.03
7.4.320.0000.16816.53
7.4.300.0030.16516.82
7.4.290.0030.20416.70
7.4.280.0000.20816.63
7.4.270.0030.20516.62
7.4.260.0070.20013.50
7.4.250.0030.20516.61
7.4.240.0070.20616.86
7.4.230.0070.20416.61
7.4.220.0130.32716.84
7.4.210.0070.32916.80
7.4.200.0070.20216.91
7.4.190.0000.20816.53
7.4.160.0070.27816.80
7.4.150.0070.27117.40
7.4.140.0100.29217.86
7.4.130.0130.34816.76
7.4.120.0050.26916.69
7.4.110.0100.28116.66
7.4.100.0100.29016.73
7.4.90.0130.28016.64
7.4.80.0160.34219.39
7.4.70.0070.33116.69
7.4.60.0130.36216.72
7.4.50.0030.17916.88
7.4.40.0170.29722.77
7.4.30.0060.33716.74
7.3.330.0000.20413.45
7.3.320.0030.23013.59
7.3.310.0030.20516.45
7.3.300.0070.20016.60
7.3.290.0070.26716.57
7.3.280.0100.37316.61
7.3.270.0100.31717.40
7.3.260.0120.38818.24
7.3.250.0110.39516.79
7.3.240.0030.28816.85
7.3.230.0100.27116.61
7.3.210.0060.30116.94
7.3.200.0060.31619.39
7.3.190.0170.33216.54
7.3.180.0130.28816.97
7.3.170.0090.34216.91
7.3.160.0060.27916.79
7.2.330.0060.33616.73
7.2.320.0060.33016.94
7.2.310.0100.33817.05
7.2.300.0100.30917.07
7.2.290.0170.31116.92
7.1.60.0670.51733.36
7.1.50.1000.47033.16
7.1.40.0530.45333.05
7.1.30.0370.43733.12
7.1.20.0870.37732.94
7.1.10.0300.57014.94
7.1.00.0150.33318.94
7.0.200.0900.45014.93
7.0.190.0600.59315.13
7.0.180.0370.52714.69
7.0.170.0330.49714.58
7.0.160.0400.67314.63
7.0.150.0370.48014.45
7.0.140.0150.44218.42
7.0.130.0430.50714.88
7.0.120.0300.41714.91
7.0.110.0200.42714.64
7.0.100.0120.38017.45
7.0.90.0180.40717.44
7.0.80.0200.38517.49
7.0.70.0130.45517.41
7.0.60.0250.47017.40
7.0.50.0280.36717.57
7.0.40.0130.39017.78
7.0.30.0220.40317.58
7.0.20.0150.38817.73
7.0.10.0130.38717.53
7.0.00.0170.37517.70
5.6.300.0001.10020.91
5.6.290.0231.09720.96
5.6.280.0170.88021.26
5.6.270.0101.18020.93
5.6.260.0201.16020.98
5.6.250.0120.92521.03
5.6.240.0200.88721.12
5.6.230.0080.87820.99
5.6.220.0171.05220.96
5.6.210.0250.99320.99
5.6.200.0100.81821.18
5.6.190.0120.85521.15
5.6.180.0080.85321.23
5.6.170.0080.89221.24
5.6.160.0100.82221.26
5.6.150.0170.80721.24
5.6.140.0050.83321.23
5.6.130.0150.90221.19
5.6.120.0030.84721.15
5.6.110.0220.86021.16
5.6.100.0220.83821.29
5.6.90.0070.84221.11
5.6.80.0120.84520.66
5.6.70.0300.79520.69
5.6.60.0130.88220.56
5.6.50.0080.89720.57
5.6.40.0100.99520.46
5.6.30.0120.89020.58
5.6.20.0180.87020.53
5.6.10.0080.88320.63
5.6.00.0050.84720.59
5.5.380.0170.94519.31
5.5.370.0080.89519.19
5.5.360.0150.90219.15
5.5.350.0130.90719.23
5.5.340.0130.92019.61
5.5.330.0050.83019.77
5.5.320.0101.11019.72
5.5.310.0130.95719.63
5.5.300.0070.88519.77
5.5.290.0170.96719.58
5.5.280.0151.10519.66
5.5.270.0100.85719.72
5.5.260.0050.84019.67
5.5.250.0130.95219.49
5.5.240.0180.90518.97
5.5.230.0030.94319.05
5.5.220.0120.86218.94
5.5.210.0450.83518.97
5.5.200.0081.00718.91
5.5.190.0050.94519.05
5.5.180.0020.98219.07
5.5.160.0080.92219.12
5.5.150.0280.99318.89
5.5.140.0100.87319.09
5.5.130.0070.89719.07
5.5.120.0130.89819.07
5.5.110.0070.98518.90
5.5.100.0100.90818.95
5.5.90.0170.90319.01
5.5.80.0171.00318.96
5.5.70.0130.93218.99
5.5.60.0220.81818.90
5.5.50.0630.82318.92
5.5.40.0080.85218.96
5.5.30.0130.96518.93
5.5.20.0070.89818.97
5.5.10.0150.93018.89
5.5.00.0120.87318.98
5.4.450.0130.86719.62
5.4.440.0080.96219.50
5.4.430.0130.86019.60
5.4.420.0100.94819.56
5.4.410.0050.97219.32
5.4.400.0150.88819.22
5.4.390.0050.83719.17
5.4.380.0080.90019.26
5.4.370.0130.94319.20
5.4.360.0070.91719.37
5.4.350.0070.90519.20
5.4.340.0130.87219.10
5.4.320.0080.89219.31
5.4.310.0150.94819.21
5.4.300.0170.91219.15
5.4.290.0150.86219.29
5.4.280.0070.87219.24
5.4.270.0050.88219.15
5.4.260.0030.90219.12
5.4.250.0170.96819.19
5.4.240.0150.96319.27
5.4.230.0101.05319.21
5.4.220.0170.89719.26
5.4.210.0120.87819.19
5.4.200.0280.89219.12
5.4.190.0070.85319.19
5.4.180.0130.91519.12
5.4.170.0270.95819.14
5.4.160.0101.05019.21
5.4.150.0070.87219.39
5.4.140.0130.85816.83
5.4.130.0100.83716.72
5.4.120.0100.86516.76
5.4.110.0220.92816.70
5.4.100.0180.88316.77
5.4.90.0050.95716.82
5.4.80.0080.92516.67
5.4.70.0070.86016.74
5.4.60.0170.89816.67
5.4.50.0130.90016.80
5.4.40.0200.88716.75
5.4.30.0181.01316.71
5.4.20.0080.90316.76
5.4.10.0130.84216.79
5.4.00.0130.86816.24
5.3.290.0070.06314.65
5.3.280.0050.04514.59
5.3.270.0180.04214.59
5.3.260.0050.05814.63
5.3.250.0130.05714.65
5.3.240.0080.04014.61
5.3.230.0130.03514.43
5.3.220.0080.04014.41
5.3.210.0080.06514.52
5.3.200.0050.04514.49
5.3.190.0070.04314.56
5.3.180.0070.05514.63
5.3.170.0080.06514.48
5.3.160.0120.04714.56
5.3.150.0050.04314.48
5.3.140.0100.05814.52
5.3.130.0050.04714.52
5.3.120.0070.04714.57
5.3.110.0050.04714.55
5.3.100.0030.04514.05
5.3.90.0050.05514.05
5.3.80.0120.05313.98
5.3.70.0020.06214.02
5.3.60.0100.05714.08
5.3.50.0070.04713.85
5.3.40.0020.04513.87
5.3.30.0050.03813.95
5.3.20.0080.03813.71
5.3.10.0070.04713.65
5.3.00.0070.04313.70
5.2.170.0100.05211.07
5.2.160.0100.03511.03
5.2.150.0020.05311.22
5.2.140.0080.03211.06
5.2.130.0070.03311.08
5.2.120.0070.03711.19
5.2.110.0020.03511.17
5.2.100.0070.03511.07
5.2.90.0050.03810.96
5.2.80.0070.03711.21
5.2.70.0050.05311.15
5.2.60.0050.04210.97
5.2.50.0100.03711.12
5.2.40.0050.04011.11
5.2.30.0050.03811.05
5.2.20.0080.03811.08
5.2.10.0050.03310.89
5.2.00.0070.03710.70
5.1.60.0050.03310.03
5.1.50.0050.03510.03
5.1.40.0050.03710.07
5.1.30.0050.03210.39
5.1.20.0030.03210.39
5.1.10.0030.03010.15
5.1.00.0050.02810.05
5.0.50.0020.0238.61
5.0.40.0020.0258.35
5.0.30.0050.0408.34
5.0.20.0050.0208.20
5.0.10.0020.0278.13
5.0.00.0030.0338.30
4.4.90.0050.0208.12
4.4.80.0020.0238.12
4.4.70.0000.0228.12
4.4.60.0050.0208.12
4.4.50.0000.0258.12
4.4.40.0050.0278.12
4.4.30.0020.0188.12
4.4.20.0000.0278.12
4.4.10.0000.0258.12
4.4.00.0050.0278.12
4.3.110.0020.0188.12
4.3.100.0050.0188.12
4.3.90.0030.0188.12
4.3.80.0030.0278.12
4.3.70.0000.0208.12
4.3.60.0020.0258.12
4.3.50.0020.0178.12
4.3.40.0020.0338.12
4.3.30.0000.0208.12
4.3.20.0050.0188.12
4.3.10.0000.0238.12
4.3.00.0050.0188.12

preferences:
47.36 ms | 401 KiB | 5 Q