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.1, 5, 0.1); $ratingCoefOptions = range(20, 10000, 20); $results = []; foreach ( $starCoefOptions as $starCoef ) { foreach ( $ratingCoefOptions as $ratingCoef ) { $topGenerated = buildTop($hotels, $starCoef, $ratingCoef); $topGenerated = array_slice($topGenerated, 0, count($top)); if ( $topGenerated === $top ) { $results[strval($starCoef)][] = $ratingCoef; } } } foreach ( $results as $starCoef=>$ratingCoefs ) { echo $starCoef.': '.min($ratingCoefs).' - '.max($ratingCoefs)."\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.0100.10018.43
8.3.50.0100.11721.20
8.3.40.0100.10719.10
8.3.30.0030.11019.33
8.3.20.0100.04920.62
8.3.10.0030.05522.21
8.3.00.0130.04422.63
8.2.180.0030.11716.87
8.2.170.0130.09622.96
8.2.160.0070.10019.45
8.2.150.0070.05224.18
8.2.140.0030.05624.66
8.2.130.0130.05926.16
8.2.120.0000.05720.08
8.2.110.0100.09922.33
8.2.100.0070.08519.70
8.2.90.0000.09119.47
8.2.80.0070.08318.18
8.2.70.0030.08717.61
8.2.60.0030.08518.29
8.2.50.0070.08218.07
8.2.40.0030.08520.32
8.2.30.0070.08118.29
8.2.20.0030.08417.96
8.2.10.0070.08117.91
8.2.00.0070.08218.04
8.1.280.0100.10025.92
8.1.270.0030.05822.36
8.1.260.0030.05526.35
8.1.250.0100.05828.09
8.1.240.0070.10024.23
8.1.230.0030.08619.26
8.1.220.0030.08717.93
8.1.210.0100.07918.77
8.1.200.0070.08217.38
8.1.190.0070.08017.78
8.1.180.0070.08218.93
8.1.170.0000.08718.77
8.1.160.0060.07822.32
8.1.150.0100.07818.83
8.1.140.0030.08617.59
8.1.130.0030.08118.05
8.1.120.0070.08017.66
8.1.110.0030.08517.68
8.1.100.0000.09217.75
8.1.90.0030.08517.70
8.1.80.0030.08317.73
8.1.70.0030.08517.61
8.1.60.0030.11017.76
8.1.50.0030.10617.67
8.1.40.0030.10617.76
8.1.30.0030.10717.72
8.1.20.0030.10617.92
8.1.10.0030.10617.70
8.1.00.0030.10917.75
8.0.300.0030.08218.77
8.0.290.0030.08617.55
8.0.280.0030.08418.69
8.0.270.0030.08517.40
8.0.260.0030.08416.92
8.0.250.0070.07917.06
8.0.240.0000.09017.16
8.0.230.0030.08417.17
8.0.220.0030.08617.03
8.0.210.0000.08617.14
8.0.200.0030.08617.03
8.0.190.0100.10017.07
8.0.180.0030.10717.07
8.0.170.0070.10517.01
8.0.160.0030.10617.14
8.0.150.0030.10616.94
8.0.140.0100.09917.03
8.0.130.0030.10813.46
8.0.120.0000.10917.05
8.0.110.0030.10717.04
8.0.100.0030.10617.04
8.0.90.0060.11117.12
8.0.80.0100.19417.07
8.0.70.0030.10917.14
8.0.60.0100.10217.04
8.0.50.0000.11017.16
8.0.30.0110.16817.38
8.0.20.0130.17117.45
8.0.10.0000.11017.26
8.0.00.0080.15917.11
7.4.330.0070.08515.00
7.4.320.0030.08416.66
7.4.300.0030.08316.84
7.4.290.0070.11616.86
7.4.280.0100.09816.85
7.4.270.0070.10016.79
7.4.260.0030.10716.76
7.4.250.0070.10416.66
7.4.240.0030.10516.67
7.4.230.0000.10716.94
7.4.220.0160.27616.73
7.4.210.0100.17416.81
7.4.200.0030.10416.77
7.4.190.0070.10116.71
7.4.160.0100.14216.86
7.4.150.0030.16017.40
7.4.140.0100.20817.86
7.4.130.0130.16216.76
7.4.120.0100.16416.66
7.4.110.0190.13516.77
7.4.100.0220.23916.86
7.4.90.0100.14716.68
7.4.80.0220.14919.39
7.4.70.0130.15016.66
7.4.60.0100.14616.76
7.4.50.0030.10016.73
7.4.40.0070.15422.77
7.4.30.0090.14016.61
7.4.00.0100.15714.95
7.3.330.0000.12513.40
7.3.320.0000.10713.60
7.3.310.0030.10316.61
7.3.300.0030.10316.62
7.3.290.0130.13616.59
7.3.280.0130.15416.63
7.3.270.0200.14017.40
7.3.260.0030.15016.86
7.3.250.0080.15316.82
7.3.240.0100.14016.54
7.3.230.0100.14616.84
7.3.210.0150.18016.57
7.3.200.0100.16319.39
7.3.190.0090.19716.63
7.3.180.0060.15816.65
7.3.170.0100.15616.80
7.3.160.0030.15116.63
7.3.120.0100.14915.13
7.2.330.0070.16417.06
7.2.320.0100.16917.02
7.2.310.0070.16316.80
7.2.300.0060.16217.03
7.2.290.0160.15716.70
7.2.00.0070.10019.60
7.1.200.0030.12716.20
7.1.100.0070.11318.41
7.1.70.0030.10817.43
7.1.60.0070.18519.82
7.1.50.0200.11717.31
7.1.00.0070.14322.66
7.0.200.0000.14517.00
7.0.140.0030.23022.26
7.0.60.0030.18020.29
7.0.50.0200.20318.38
7.0.40.0030.16020.54
7.0.30.0270.20320.68
7.0.20.0230.15320.61
7.0.10.0070.18720.38
7.0.00.0070.16020.61
5.6.280.0130.42021.55
5.6.210.0030.30021.08
5.6.200.0070.36318.70
5.6.190.0070.34720.86
5.6.180.0470.35020.91
5.6.170.0270.33020.85
5.6.160.0130.35321.02
5.6.150.0070.29718.62
5.6.140.0870.31018.66
5.6.130.0030.32018.49
5.6.120.0200.35721.43
5.6.110.0130.38321.46
5.6.100.0170.37021.45
5.6.90.0130.32321.58
5.6.80.0070.33320.82
5.5.350.0200.39720.84
5.5.340.0130.37318.56
5.5.330.0070.37320.88
5.5.320.1630.36320.79
5.5.310.0230.38720.55
5.5.300.0070.35318.45
5.5.290.0030.40718.36
5.5.280.0100.38021.39
5.5.270.0070.38021.16
5.5.260.0030.37321.34
5.5.250.0030.40320.96
5.5.240.0130.34020.69
5.4.450.0400.54019.85
5.4.440.0230.51719.66
5.4.430.0100.55019.95
5.4.420.0200.55019.66
5.4.410.0100.62319.25
5.4.400.0170.71719.00
5.4.390.1030.68018.97
5.4.380.0230.61318.78
5.4.370.0170.50718.89
5.4.360.0170.53018.80
5.4.350.0400.51318.98
5.4.340.0300.52318.87
5.4.320.0080.40612.68
5.4.310.0080.41912.67
5.4.300.0060.43812.68
5.4.290.0060.40212.67
5.4.280.0330.71212.54
5.4.270.0230.73212.54
5.4.260.0340.71812.54
5.4.250.0231.06812.54
5.4.240.0131.04412.54
5.4.230.0120.83012.53
5.4.220.0291.03012.53
5.4.210.0230.96312.54
5.4.200.0291.15612.53
5.4.190.0220.96812.53
5.4.180.0170.87312.53
5.4.170.0171.05712.54
5.4.160.0210.81412.53
5.4.150.0110.84512.52
5.4.140.0140.90512.21
5.4.130.0140.76012.20
5.4.120.0120.80112.16
5.4.110.0130.74812.16
5.4.100.0130.79512.15
5.4.90.0110.78712.15
5.4.80.0070.81012.16
5.4.70.0070.62812.15
5.4.60.0130.80912.14
5.4.50.0210.79212.15
5.4.40.0110.78912.14
5.4.30.0150.78512.13
5.4.20.0140.80012.13
5.4.10.0110.76312.13
5.4.00.0130.82611.63
5.3.290.0070.04112.80
5.3.280.0120.05412.71
5.3.270.0120.05712.72
5.3.260.0100.05312.72
5.3.250.0120.06812.72
5.3.240.0100.08212.72
5.3.230.0160.07112.71
5.3.220.0120.07112.68
5.3.210.0090.05112.68
5.3.200.0100.05912.68
5.3.190.0100.05212.68
5.3.180.0110.05612.67
5.3.170.0100.05012.67
5.3.160.0190.06712.67
5.3.150.0160.05912.68
5.3.140.0080.06912.66
5.3.130.0150.07612.66
5.3.120.0120.06212.66
5.3.110.0090.07312.66
5.3.100.0100.05812.12
5.3.90.0150.06212.08
5.3.80.0100.05012.07
5.3.70.0060.05412.08
5.3.60.0080.05612.06
5.3.50.0110.05112.00
5.3.40.0150.07212.00
5.3.30.0160.06511.94
5.3.20.0150.05411.70
5.3.10.0150.08311.67
5.3.00.0220.11411.66
5.2.170.0130.0579.15
5.2.160.0080.0789.16
5.2.150.0050.0759.15
5.2.140.0070.0489.15
5.2.130.0050.0379.11
5.2.120.0040.0299.11
5.2.110.0050.0309.11
5.2.100.0040.0369.11
5.2.90.0150.0659.11
5.2.80.0090.0359.11
5.2.70.0080.0289.11
5.2.60.0020.0349.06
5.2.50.0080.0299.03
5.2.40.0090.0289.01
5.2.30.0250.0998.98
5.2.20.0090.0728.97
5.2.10.0360.0868.90
5.2.00.0090.0438.76
5.1.60.0060.0358.05
5.1.50.0020.0678.05
5.1.40.0260.0948.03
5.1.30.0050.0398.38
5.1.20.0060.0288.39
5.1.10.0070.0268.13
5.1.00.0090.0358.12
5.0.50.0050.0276.60
5.0.40.0040.0316.46
5.0.30.0100.0436.27
5.0.20.0050.0306.24
5.0.10.0030.0226.22
5.0.00.0030.0346.21
4.4.90.0050.0184.78
4.4.80.0030.0174.76
4.4.70.0040.0314.75
4.4.60.0060.0194.75
4.4.50.0090.0274.77
4.4.40.0060.0384.71
4.4.30.0090.0294.76
4.4.20.0120.0294.84
4.4.10.0030.0194.85
4.4.00.0060.0464.76
4.3.110.0050.0214.67
4.3.100.0030.0244.66
4.3.90.0020.0244.64
4.3.80.0050.0394.58
4.3.70.0060.0214.63
4.3.60.0110.0284.63
4.3.50.0060.0284.63
4.3.40.0030.0324.54
4.3.30.0020.0223.27
4.3.20.0070.0243.25
4.3.10.0090.0923.21
4.3.00.0170.0276.83

preferences:
44.42 ms | 401 KiB | 5 Q