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); $starCoefOptions = array(0.1, 0.2); $ratingCoefOptions = array(1000, 2000); foreach ( $starCoefOptions as $starCoef ) { foreach ( $ratingCoefOptions as $ratingCoef ) { $topGenerated = buildTop($hotels, $starCoef, $ratingCoef); $topGenerated = array_slice($topGenerated, 0, count($top)); var_dump($topGenerated); 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.0150.00019.07
8.3.30.0150.00418.87
8.3.20.0080.00020.78
8.3.10.0050.00321.29
8.3.00.0000.00722.01
8.2.170.0140.00722.96
8.2.160.0070.00720.47
8.2.150.0000.00924.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0040.00421.18
8.2.110.0090.00020.60
8.2.100.0070.00418.16
8.2.90.0040.00419.48
8.2.80.0040.00417.97
8.2.70.0000.01417.75
8.2.60.0060.00318.05
8.2.50.0060.00318.07
8.2.40.0060.00318.47
8.2.30.0040.00419.66
8.2.20.0040.00417.93
8.2.10.0070.00017.85
8.2.00.0060.00317.89
8.1.270.0040.00424.66
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0060.00621.00
8.1.230.0030.00821.16
8.1.220.0050.00318.77
8.1.210.0100.00019.10
8.1.200.0040.00417.60
8.1.190.0060.00317.77
8.1.180.0080.00018.10
8.1.170.0000.00918.79
8.1.160.0040.00419.01
8.1.150.0000.00718.86
8.1.140.0000.00717.58
8.1.130.0000.00818.00
8.1.120.0070.00017.68
8.1.110.0080.00017.74
8.1.100.0080.00017.70
8.1.90.0040.00417.65
8.1.80.0000.00717.66
8.1.70.0040.00417.57
8.1.60.0090.00017.82
8.1.50.0040.00417.61
8.1.40.0030.00617.70
8.1.30.0030.00617.91
8.1.20.0050.00317.83
8.1.10.0000.00917.65
8.1.00.0040.00417.67
8.0.300.0080.00020.23
8.0.290.0000.00717.30
8.0.280.0000.00718.66
8.0.270.0040.00417.36
8.0.260.0000.00717.05
8.0.250.0050.00217.21
8.0.240.0030.00617.22
8.0.230.0070.00017.20
8.0.220.0020.00517.05
8.0.210.0080.00017.13
8.0.200.0000.00717.14
8.0.190.0000.00717.11
8.0.180.0060.00317.03
8.0.170.0030.00617.17
8.0.160.0080.00017.17
8.0.150.0070.00016.96
8.0.140.0000.00817.04
8.0.130.0030.00313.55
8.0.120.0000.00717.10
8.0.110.0050.00317.23
8.0.100.0050.00217.02
8.0.90.0040.00417.07
8.0.80.0000.01516.99
8.0.70.0050.00217.09
8.0.60.0030.00517.14
8.0.50.0000.00717.14
8.0.30.0100.00917.48
8.0.20.0120.01017.40
8.0.10.0000.00717.26
8.0.00.0120.00717.00
7.4.330.0020.00217.03
7.4.320.0000.00616.87
7.4.300.0030.00316.87
7.4.290.0030.00316.82
7.4.280.0030.00316.86
7.4.270.0030.00316.80
7.4.260.0030.00313.43
7.4.250.0000.00816.84
7.4.240.0080.00016.59
7.4.230.0090.00016.83
7.4.220.0030.01616.71
7.4.210.0090.00816.76
7.4.200.0020.00516.76
7.4.190.0030.00316.69
7.4.160.0120.01216.81
7.4.150.0140.00517.40
7.4.140.0170.00617.86
7.4.130.0100.01016.78
7.4.120.0110.00716.57
7.4.110.0130.00716.94
7.4.100.0100.00816.72
7.4.90.0070.01016.54
7.4.80.0160.00019.39
7.4.70.0070.01016.57
7.4.60.0410.01516.73
7.4.50.0030.00916.49
7.4.40.0080.00822.77
7.4.30.0090.00916.85
7.4.00.0030.01315.10
7.3.330.0030.00313.54
7.3.320.0000.00513.41
7.3.310.0030.00316.43
7.3.300.0000.00616.57
7.3.290.0070.00716.58
7.3.280.0050.01316.58
7.3.270.0190.00017.40
7.3.260.0110.01018.24
7.3.250.0110.00716.69
7.3.240.0100.01016.61
7.3.230.0130.00616.61
7.3.210.0070.01016.81
7.3.200.0120.00616.50
7.3.190.0060.01216.63
7.3.180.0100.00916.85
7.3.170.0100.00616.69
7.3.160.0030.01316.47
7.3.120.0070.00715.03
7.2.330.0110.00817.07
7.2.320.0060.01316.93
7.2.310.0060.01916.80
7.2.300.0030.01416.68
7.2.290.0100.01316.71
7.2.60.0070.00717.32
7.2.00.0070.01019.65
7.1.200.0090.00316.36
7.1.100.0030.01018.40
7.1.70.0000.01017.45
7.1.60.0140.01119.40
7.1.50.0030.01317.04
7.1.00.0030.03322.66
7.0.200.0000.00817.25
7.0.140.0070.06722.36
7.0.80.0070.06020.27
7.0.70.0000.04720.25
7.0.60.0600.03720.29
7.0.50.0070.04020.58
7.0.40.0030.09020.34
7.0.30.0070.04720.33
7.0.20.0030.08720.34
7.0.10.0100.04320.43
7.0.00.0130.08020.48
5.6.280.0130.06321.41
5.6.230.0070.04720.99
5.6.220.0070.05020.89
5.6.210.0100.05321.06
5.6.200.0000.07021.26
5.6.190.0100.07721.36
5.6.180.0070.07021.39
5.6.170.0070.08721.34
5.6.160.0070.04721.36
5.6.150.0070.07721.36
5.6.140.0000.08721.48
5.6.130.0070.06321.39
5.6.120.0300.06021.39
5.6.110.0000.06321.30
5.6.100.0100.08321.48
5.6.90.0100.08321.41
5.6.80.0030.08720.73
5.6.70.0130.07320.73
5.6.60.0100.08020.77
5.6.50.0070.07720.66
5.6.40.0070.07720.81
5.6.30.0000.07320.66
5.6.20.0000.04320.80
5.6.10.0000.05320.80
5.6.00.0030.09020.71
5.5.370.0000.05020.75
5.5.360.0070.05020.81
5.5.350.0200.06020.73
5.5.340.0000.08321.23
5.5.330.0000.08321.18
5.5.320.0030.06721.19
5.5.310.0100.05721.14
5.5.300.0130.04721.11
5.5.290.0200.07321.09
5.5.280.0130.03321.18
5.5.270.0100.08021.13
5.5.260.0170.05021.22
5.5.250.0070.07321.11
5.5.240.0070.04320.59
5.5.230.0000.07720.59
5.5.220.0030.05020.46
5.5.210.0030.08720.49
5.5.200.0000.08020.53
5.5.190.0030.08020.56
5.5.180.0070.07020.42
5.5.160.0170.06720.50
5.5.150.0100.04320.57
5.5.140.0170.07020.53
5.5.130.0170.06720.30
5.5.120.0130.05320.27
5.5.110.0100.04320.49
5.5.100.0130.05720.39
5.5.90.0070.07320.47
5.5.80.0030.08320.36
5.5.70.0070.07320.37
5.5.60.0070.07720.39
5.5.50.0070.06320.23
5.5.40.0270.05720.40
5.5.30.0070.07320.53
5.5.20.0000.08720.27
5.5.10.0030.05320.28
5.5.00.0030.08020.39
5.4.450.0070.08019.80
5.4.440.0030.07019.52
5.4.430.0130.05319.75
5.4.420.0030.08019.62
5.4.410.0070.07719.57
5.4.400.0130.06319.38
5.4.390.0200.04719.29
5.4.380.0000.08019.46
5.4.370.0100.05319.29
5.4.360.0100.07719.38
5.4.350.0070.05719.38
5.4.340.0070.04019.29
5.4.320.0100.07319.20
5.4.310.0170.06719.16
5.4.300.0070.07719.43
5.4.290.0030.05319.34
5.4.280.0030.08319.38
5.4.270.0130.07019.34
5.4.260.0000.07319.31
5.4.250.0100.06319.37
5.4.240.0030.05719.14
5.4.230.0030.08019.15
5.4.220.0100.07019.27
5.4.210.0030.08019.46
5.4.200.0130.06719.38
5.4.190.0030.07319.42
5.4.180.0030.07319.29
5.4.170.0130.06019.18
5.4.160.0030.08019.44
5.4.150.0100.03319.18
5.4.140.0000.07716.74
5.4.130.0030.06716.61
5.4.120.0200.04016.73
5.4.110.0200.06016.71
5.4.100.0030.07316.63
5.4.90.0070.04316.79
5.4.80.0100.06716.56
5.4.70.0030.03716.69
5.4.60.0070.03716.72
5.4.50.0070.07016.76
5.4.40.0100.03716.75
5.4.30.0070.07016.62
5.4.20.0200.05716.57
5.4.10.0070.06716.78
5.4.00.0130.03316.21
5.3.290.0030.08014.63
5.3.280.0030.05314.59
5.3.270.0000.07314.43
5.3.260.0070.07014.54
5.3.250.0100.04014.44
5.3.240.0100.07314.46
5.3.230.0070.07314.58
5.3.220.0070.04714.56
5.3.210.0070.08014.55
5.3.200.0030.04014.48
5.3.190.0000.07714.59
5.3.180.0070.04714.38
5.3.170.0070.07314.50
5.3.160.0030.07314.55
5.3.150.0000.06314.56
5.3.140.0070.07314.55
5.3.130.0200.04314.54
5.3.120.0030.07714.53
5.3.110.0030.05014.39
5.3.100.0070.07714.05
5.3.90.0070.07014.01
5.3.80.0070.03713.88
5.3.70.0070.04013.99
5.3.60.0030.04714.00
5.3.50.0100.04313.81
5.3.40.0000.04013.71
5.3.30.0030.04013.90
5.3.20.0070.03713.46
5.3.10.0030.03713.65
5.3.00.0070.06713.49
5.2.170.0070.04311.77
5.2.160.0000.04011.77
5.2.150.0070.03311.77
5.2.140.0070.05011.77
5.2.130.0070.04011.77
5.2.120.0070.05011.77
5.2.110.0030.03311.77
5.2.100.0030.02711.77
5.2.90.0000.03011.77
5.2.80.0000.03011.77
5.2.70.0030.02711.77
5.2.60.0070.03711.77
5.2.50.0030.02711.77
5.2.40.0130.02311.77
5.2.30.0030.02711.77
5.2.20.0070.02311.77
5.2.10.0100.02011.77
5.2.00.0030.02711.77
5.1.60.0000.02711.77
5.1.50.0070.05311.77
5.1.40.0000.05311.77
5.1.30.0000.03711.77
5.1.20.0030.03311.77
5.1.10.0000.05311.77
5.1.00.0030.02311.77
5.0.50.0000.02011.77
5.0.40.0100.03011.77
5.0.30.0000.03311.77
5.0.20.0000.02011.77
5.0.10.0000.02011.77
5.0.00.0000.02711.77
4.4.90.0030.01711.77
4.4.80.0030.01311.77
4.4.70.0030.01711.77
4.4.60.0000.01311.77
4.4.50.0000.01311.77
4.4.40.0000.02311.77
4.4.30.0000.01311.77
4.4.20.0000.01711.77
4.4.10.0000.02011.77
4.4.00.0030.04711.77
4.3.110.0000.02311.77
4.3.100.0030.01311.77
4.3.90.0030.01311.77
4.3.80.0000.03311.77
4.3.70.0000.01311.77
4.3.60.0030.03311.77
4.3.50.0030.03011.77
4.3.40.0070.04711.77
4.3.30.0100.00711.77
4.3.20.0000.01711.77
4.3.10.0000.01711.77
4.3.00.0000.01311.77

preferences:
46.25 ms | 400 KiB | 5 Q