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', 'Chaba', ]; for ( $i=0; $i<count($hotels); $i++ ) { $hotels[$i][4] = 0; } $starCoefOptions = range(0.1, 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.70.0100.13016.75
8.3.60.0130.11818.66
8.3.50.0230.14121.39
8.3.40.0070.10018.91
8.3.30.0070.10420.56
8.3.20.0160.07420.59
8.3.10.0030.05622.34
8.3.00.0070.05022.76
8.2.180.0100.11716.75
8.2.170.0130.12422.96
8.2.160.0070.09622.49
8.2.150.0060.05524.18
8.2.140.0070.05124.66
8.2.130.0030.05526.16
8.2.120.0030.05420.88
8.2.110.0100.11222.33
8.2.100.0070.08818.14
8.2.90.0070.08319.48
8.2.80.0060.07819.46
8.2.70.0060.08417.75
8.2.60.0070.08318.18
8.2.50.0000.09018.07
8.2.40.0070.08120.10
8.2.30.0000.08319.72
8.2.20.0000.08717.99
8.2.10.0000.08917.96
8.2.00.0030.09517.88
8.1.280.0100.11225.92
8.1.270.0000.05723.99
8.1.260.0000.05726.35
8.1.250.0030.05328.09
8.1.240.0030.10323.94
8.1.230.0100.08019.21
8.1.220.0000.09217.77
8.1.210.0070.08218.77
8.1.200.0000.09017.60
8.1.190.0100.07817.66
8.1.180.0000.08818.10
8.1.170.0070.07918.89
8.1.160.0030.10019.01
8.1.150.0030.08518.73
8.1.140.0030.08717.62
8.1.130.0030.07918.00
8.1.120.0000.08717.65
8.1.110.0000.08717.55
8.1.100.0070.08617.69
8.1.90.0000.08817.70
8.1.80.0030.08217.67
8.1.70.0000.08817.61
8.1.60.0070.10517.71
8.1.50.0000.10917.65
8.1.40.0030.10717.68
8.1.30.0030.10817.84
8.1.20.0030.10817.91
8.1.10.0070.10617.79
8.1.00.0070.12517.76
8.0.300.0030.08218.96
8.0.290.0030.08417.43
8.0.280.0030.08518.66
8.0.270.0030.08517.46
8.0.260.0000.08816.98
8.0.250.0030.08317.20
8.0.240.0090.11417.16
8.0.230.0030.08517.12
8.0.220.0070.08216.99
8.0.210.0070.08116.98
8.0.200.0000.08917.08
8.0.190.0070.10317.18
8.0.180.0030.11117.14
8.0.170.0000.11217.04
8.0.160.0030.10617.03
8.0.150.0030.10616.98
8.0.140.0000.11716.95
8.0.130.0030.10413.52
8.0.120.0000.11017.08
8.0.110.0000.11117.14
8.0.100.0000.13117.15
8.0.90.0000.10917.09
8.0.80.0160.17017.13
8.0.70.0100.10017.11
8.0.60.0030.10717.13
8.0.50.0100.10717.11
8.0.30.0090.15017.09
8.0.20.0150.16317.40
8.0.10.0000.11017.18
8.0.00.0160.14816.87
7.4.330.0030.09915.00
7.4.320.0030.08416.71
7.4.300.0070.07916.79
7.4.290.0100.09816.71
7.4.280.0000.10616.64
7.4.270.0100.10416.75
7.4.260.0000.12613.50
7.4.250.0030.10816.69
7.4.240.0020.10716.73
7.4.230.0000.10716.71
7.4.220.0030.17716.89
7.4.210.0040.15716.78
7.4.200.0000.10716.77
7.4.190.0070.10116.67
7.4.160.0030.14516.78
7.4.150.0070.23317.40
7.4.140.0080.13917.86
7.4.130.0120.16116.64
7.4.120.0120.13816.63
7.4.110.0070.19216.62
7.4.100.0160.18616.54
7.4.90.0130.18416.81
7.4.80.0170.13719.39
7.4.70.0170.13316.80
7.4.60.0030.15616.47
7.4.50.0070.09616.62
7.4.40.0100.16322.77
7.4.30.0070.14816.74
7.4.00.0120.19415.29
7.3.330.0030.10313.38
7.3.320.0030.10413.44
7.3.310.0030.10416.50
7.3.300.0000.10716.55
7.3.290.0070.14016.59
7.3.280.0110.22616.63
7.3.270.0070.15117.40
7.3.260.0130.19616.54
7.3.250.0110.15616.65
7.3.240.0160.15816.78
7.3.230.0000.17316.53
7.3.210.0190.20816.88
7.3.200.0160.15519.39
7.3.190.0170.20816.79
7.3.180.0130.18616.53
7.3.170.0090.13916.61
7.3.160.0030.15716.75
7.3.120.0080.19015.03
7.3.110.0070.19015.05
7.3.100.0000.24015.13
7.3.90.0030.19014.87
7.3.80.0070.16614.98
7.3.70.0030.17714.98
7.3.60.0070.14715.27
7.3.50.0030.16015.28
7.3.40.0000.22615.25
7.3.30.0000.21315.20
7.3.20.0030.18317.07
7.3.10.0070.16616.92
7.3.00.0030.18617.00
7.2.330.0060.16717.12
7.2.320.0060.15317.09
7.2.310.0130.16016.91
7.2.300.0100.16717.02
7.2.290.0150.16117.11
7.2.250.0000.20815.67
7.2.240.0030.24315.14
7.2.230.0030.18715.58
7.2.220.0070.22715.54
7.2.210.0000.21515.32
7.2.200.0030.18115.39
7.2.190.0000.19715.27
7.2.180.0030.21415.42
7.2.170.0000.16315.25
7.2.00.0160.11019.38
7.1.330.0030.31316.13
7.1.320.0030.29315.95
7.1.310.0030.29516.29
7.1.300.0030.26316.21
7.1.290.0000.31016.00
7.1.280.0070.28616.16
7.1.270.0130.29416.31
7.1.260.0070.25916.06
7.1.70.0030.16917.38
7.1.60.0070.13317.56
7.1.50.0070.16617.07
7.1.00.0070.13722.93
7.0.200.0070.12917.21
7.0.140.0070.23722.49
7.0.100.0070.15320.29
7.0.90.0030.15720.39
7.0.80.0030.21320.29
7.0.70.0200.18320.25
7.0.60.0100.21720.42
7.0.50.0070.22020.62
7.0.40.0100.21020.45
7.0.30.0100.20320.39
7.0.20.0130.23020.50
7.0.10.0130.21020.43
7.0.00.0170.21320.52
5.6.280.0000.41721.66
5.6.250.0430.29321.10
5.6.240.0030.30321.01
5.6.230.0070.39321.10
5.6.220.0130.38321.08
5.6.210.0130.40721.10
5.6.200.0030.36721.45
5.6.190.0100.36321.54
5.6.180.0070.37321.48
5.6.170.0130.36021.49
5.6.160.0030.31321.50
5.6.150.0100.31721.55
5.6.140.0170.35321.50
5.6.130.0070.36721.46
5.6.120.0100.36721.54
5.6.110.0070.36721.51
5.6.100.0100.33021.61
5.6.90.0030.37721.50
5.6.80.0070.37720.86
5.6.70.0130.33020.93
5.6.60.0100.34020.89
5.6.50.0130.36320.91
5.6.40.0130.39320.85
5.6.30.0030.37320.83
5.6.20.0100.37320.78
5.6.10.0200.35720.86
5.6.00.0100.36720.88
5.5.380.0000.32720.84
5.5.370.0030.41020.90
5.5.360.0100.38320.82
5.5.350.0100.44320.90
5.5.340.0070.34021.34
5.5.330.0170.40321.33
5.5.320.0170.39321.38
5.5.310.0070.40021.37
5.5.300.0170.38021.37
5.5.290.0100.38321.36
5.5.280.0100.38021.24
5.5.270.0070.35021.33
5.5.260.0100.41721.28
5.5.250.0130.41021.13
5.5.240.0070.39720.75
5.5.230.0030.40320.49
5.5.220.0070.41020.73
5.5.210.0100.38720.74
5.5.200.0070.35020.68
5.5.190.0100.39320.63
5.5.180.0200.39720.47
5.5.160.0230.38320.79
5.5.150.0170.37020.67
5.5.140.0170.39320.62
5.5.130.0000.37720.57
5.5.120.0030.36320.58
5.5.110.0000.41320.64
5.5.100.0070.38020.61
5.5.90.0100.40320.61
5.5.80.0070.35720.56
5.5.70.0070.37320.57
5.5.60.0030.40320.50
5.5.50.0070.40720.53
5.5.40.0170.37720.62
5.5.30.0070.40720.55
5.5.20.0130.39720.57
5.5.10.0000.39020.50
5.5.00.0100.40320.54
5.4.450.0100.32319.79
5.4.440.0070.40019.74
5.4.430.0100.38319.77
5.4.420.0070.39319.74
5.4.410.0030.37719.70
5.4.400.0070.37019.58
5.4.390.0070.42019.36
5.4.380.0030.39319.55
5.4.370.0030.38719.46
5.4.360.0070.38719.45
5.4.350.0130.37319.50
5.4.340.0070.41019.42
5.4.320.0070.38719.60
5.4.310.0100.39319.51
5.4.300.0200.38719.42
5.4.290.0030.39319.30
5.4.280.0030.39319.45
5.4.270.0170.38319.57
5.4.260.0100.37719.50
5.4.250.0030.37019.45
5.4.240.0030.37719.55
5.4.230.0100.32719.54
5.4.220.0100.36719.50
5.4.210.0100.38319.45
5.4.200.0070.36019.39
5.4.190.0100.41719.59
5.4.180.0000.37319.34
5.4.170.0030.39019.51
5.4.160.0000.41019.34
5.4.150.0030.35019.49
5.4.140.0070.34016.79
5.4.130.0030.39316.75
5.4.120.0030.38716.94
5.4.110.0030.39016.93
5.4.100.0070.38016.89
5.4.90.0000.39016.86
5.4.80.0100.34316.88
5.4.70.0030.40316.87
5.4.60.0100.38716.87
5.4.50.0070.38716.73
5.4.40.0070.39316.86
5.4.30.0070.37316.86
5.4.20.0030.35016.90
5.4.10.0000.33316.91
5.4.00.0000.33316.28
5.3.290.0100.07314.50
5.3.280.0130.07014.59
5.3.270.0000.04014.56
5.3.260.0070.05014.47
5.3.250.0030.06014.55
5.3.240.0070.07714.60
5.3.230.0070.06714.57
5.3.220.0070.06314.53
5.3.210.0070.04014.40
5.3.200.0030.04314.57
5.3.190.0070.07714.55
5.3.180.0100.06714.50
5.3.170.0100.08014.44
5.3.160.0070.04714.43
5.3.150.0070.07314.39
5.3.140.0130.06314.42
5.3.130.0000.08314.37
5.3.120.0100.04014.55
5.3.110.0130.02714.41
5.3.100.0000.04014.02
5.3.90.0070.03313.98
5.3.80.0070.03714.02
5.3.70.0030.04313.77
5.3.60.0030.03713.86
5.3.50.0070.03313.91
5.3.40.0000.04013.80
5.3.30.0070.04313.66
5.3.20.0030.03013.63
5.3.10.0030.04013.67
5.3.00.0070.03313.55
5.2.170.0030.03312.37
5.2.160.0070.04012.37
5.2.150.0030.06312.37
5.2.140.0030.04012.37
5.2.130.0070.02712.37
5.2.120.0030.02712.37
5.2.110.0100.02312.37
5.2.100.0030.03012.37
5.2.90.0030.03312.37
5.2.80.0000.03012.37
5.2.70.0030.02712.37
5.2.60.0000.03312.37
5.2.50.0030.02712.37
5.2.40.0000.05312.37
5.2.30.0000.03012.37
5.2.20.0000.03312.37
5.2.10.0030.02312.37
5.2.00.0030.03012.37
5.1.60.0030.02712.37
5.1.50.0000.02712.37
5.1.40.0000.03012.37
5.1.30.0000.04712.37
5.1.20.0070.02712.37
5.1.10.0070.02012.37
5.1.00.0000.02312.37
5.0.50.0000.02312.37
5.0.40.0030.03712.37
5.0.30.0030.03712.37
5.0.20.0030.02312.37
5.0.10.0000.02312.37
5.0.00.0030.07012.37
4.4.90.0030.01312.37
4.4.80.0000.01712.37
4.4.70.0000.01712.37
4.4.60.0000.02012.37
4.4.50.0000.01312.37
4.4.40.0000.02712.37
4.4.30.0000.01712.37
4.4.20.0000.01712.37
4.4.10.0030.01312.37
4.4.00.0030.02712.37
4.3.110.0070.02012.37
4.3.100.0030.01712.37
4.3.90.0000.03012.37
4.3.80.0000.04312.37
4.3.70.0000.03312.37
4.3.60.0000.03312.37
4.3.50.0100.02312.37
4.3.40.0000.05312.37
4.3.30.0070.03012.37
4.3.20.0000.02312.37
4.3.10.0030.03712.37
4.3.00.0030.02712.37

preferences:
34.28 ms | 401 KiB | 5 Q