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', 'Ya', '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); $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.0130.10918.53
8.3.50.0100.10822.11
8.3.40.0100.10419.04
8.3.30.0070.10519.47
8.3.20.0030.05520.54
8.3.10.0000.06022.15
8.3.00.0100.04722.59
8.2.180.0100.10616.88
8.2.170.0130.11622.96
8.2.160.0070.09821.19
8.2.150.0030.05524.18
8.2.140.0070.05224.66
8.2.130.0070.07226.16
8.2.120.0100.04917.59
8.2.110.0070.10421.36
8.2.100.0030.08918.16
8.2.90.0030.08619.60
8.2.80.0000.08918.18
8.2.70.0100.08118.00
8.2.60.0100.08118.30
8.2.50.0000.09218.07
8.2.40.0030.08518.72
8.2.30.0070.08218.29
8.2.20.0070.08118.07
8.2.10.0030.08517.95
8.2.00.0030.08718.04
8.1.280.0100.09925.92
8.1.270.0060.05222.51
8.1.260.0000.05826.35
8.1.250.0070.04928.09
8.1.240.0030.10324.28
8.1.230.0030.08419.54
8.1.220.0070.08418.02
8.1.210.0030.08518.77
8.1.200.0070.08317.61
8.1.190.0070.09517.77
8.1.180.0030.08419.09
8.1.170.0070.07919.02
8.1.160.0030.08122.39
8.1.150.0030.08518.85
8.1.140.0030.08517.64
8.1.130.0070.07918.15
8.1.120.0000.08817.75
8.1.110.0030.08417.79
8.1.100.0030.09217.80
8.1.90.0030.08617.77
8.1.80.0030.08417.82
8.1.70.0000.08917.65
8.1.60.0070.10517.95
8.1.50.0000.11117.85
8.1.40.0000.11117.88
8.1.30.0100.10117.89
8.1.20.0070.10617.82
8.1.10.0030.10617.84
8.1.00.0030.10917.66
8.0.300.0000.08518.77
8.0.290.0030.08717.55
8.0.280.0060.08118.77
8.0.270.0030.09317.57
8.0.260.0030.10316.98
8.0.250.0030.08317.29
8.0.240.0030.08817.20
8.0.230.0030.10117.29
8.0.220.0070.08317.14
8.0.210.0030.08317.10
8.0.200.0030.08817.29
8.0.190.0030.10917.31
8.0.180.0070.10617.24
8.0.170.0030.10917.13
8.0.160.0030.10717.23
8.0.150.0030.10917.15
8.0.140.0030.10617.16
8.0.130.0000.11013.66
8.0.120.0030.10917.07
8.0.110.0030.10917.12
8.0.100.0000.11017.13
8.0.90.0030.11517.10
8.0.80.0060.21417.09
8.0.70.0030.11217.16
8.0.60.0030.10717.34
8.0.50.0030.10717.04
8.0.30.0060.16417.40
8.0.20.0110.16017.51
8.0.10.0030.10717.20
8.0.00.0130.15317.16
7.4.330.0030.08815.35
7.4.320.0000.08816.84
7.4.300.0000.08816.82
7.4.290.0030.10516.78
7.4.280.0030.10616.76
7.4.270.0030.10616.89
7.4.260.0070.11416.72
7.4.250.0030.10716.89
7.4.240.0050.10416.90
7.4.230.0030.10616.93
7.4.220.0030.17916.86
7.4.210.0120.15716.83
7.4.200.0070.10316.89
7.4.190.0100.10316.92
7.4.160.0070.15616.70
7.4.150.0060.14517.40
7.4.140.0070.15917.86
7.4.130.0100.17616.81
7.4.120.0050.19616.86
7.4.110.0130.14016.96
7.4.100.0100.21716.96
7.4.90.0090.22416.77
7.4.80.0060.25019.39
7.4.70.0130.14616.79
7.4.60.0030.16016.74
7.4.50.0030.07816.86
7.4.40.0070.15722.77
7.4.30.0160.13416.96
7.4.00.0070.15515.33
7.3.330.0070.10113.67
7.3.320.0030.10213.56
7.3.310.0030.10316.54
7.3.300.0030.10316.74
7.3.290.0030.16116.66
7.3.280.0130.16316.71
7.3.270.0130.15117.40
7.3.260.0100.26216.68
7.3.250.0110.15316.67
7.3.240.0130.14416.80
7.3.230.0100.14816.71
7.3.210.0070.17416.75
7.3.200.0130.19119.39
7.3.190.0130.25616.62
7.3.180.0150.14517.05
7.3.170.0090.16416.62
7.3.160.0100.14216.73
7.3.120.0030.16315.32
7.2.330.0130.17716.95
7.2.320.0130.14716.82
7.2.310.0030.24317.18
7.2.300.0030.16616.81
7.2.290.0130.21317.21
7.2.00.0030.15919.69
7.1.100.0030.12418.69
7.1.70.0000.12317.57
7.1.60.0070.17819.82
7.1.50.0100.18017.36
7.1.00.0000.24022.85
7.0.200.0030.11417.16
7.0.140.0030.18722.62
7.0.60.0100.21720.47
7.0.50.0030.15718.38
7.0.40.0100.17720.34
7.0.30.0270.18320.41
7.0.20.0270.20020.37
7.0.10.0170.16020.61
7.0.00.0070.18720.60
5.6.280.0070.42021.93
5.6.210.0070.39321.36
5.6.200.0030.33718.87
5.6.190.0070.30321.18
5.6.180.4200.30721.12
5.6.170.0230.30720.89
5.6.160.0100.35021.14
5.6.150.0100.36718.76
5.6.140.0170.35318.86
5.6.130.0030.38018.87
5.6.120.0000.37021.86
5.6.110.0130.34321.78
5.6.100.0130.35321.69
5.6.90.0100.36321.77
5.6.80.0100.32021.21
5.6.70.0300.34721.20
5.5.350.0070.26721.09
5.5.340.0170.37318.62
5.5.330.0100.35720.76
5.5.320.0230.33020.82
5.5.310.0130.32320.85
5.5.300.0000.35318.61
5.5.290.0070.32718.72
5.5.280.0100.32321.43
5.5.270.0170.40021.39
5.5.260.0100.38021.53
5.5.250.0170.40721.20
5.5.240.0100.38321.08
5.4.450.0430.54019.65
5.4.440.0700.54719.68
5.4.430.0600.54320.09
5.4.420.0500.54319.86
5.4.410.0500.55320.11
5.4.400.6270.00018.93
5.4.390.5670.00019.17
5.4.380.0270.52319.18
5.4.370.0230.53319.22
5.4.360.0230.52719.23
5.4.350.0300.51719.26
5.4.340.0230.55318.93
5.4.320.0080.43312.86
5.4.310.0100.40212.86
5.4.300.0080.41912.87
5.4.290.0050.40112.86
5.4.280.0100.68612.73
5.4.270.0100.48512.72
5.4.260.0090.53312.73
5.4.250.0120.47712.72
5.4.240.0110.52212.73
5.4.230.0080.53612.72
5.4.220.0120.80712.72
5.4.210.0130.63112.71
5.4.200.0090.46912.71
5.4.190.0090.72112.71
5.4.180.0100.77412.72
5.4.170.0080.70912.72
5.4.160.0100.58412.72
5.4.150.0110.49212.71
5.4.140.0110.74112.40
5.4.130.0110.84412.39
5.4.120.0170.82412.34
5.4.110.0100.70712.34
5.4.100.0120.71512.34
5.4.90.0080.71512.34
5.4.80.0090.74712.34
5.4.70.0120.70812.34
5.4.60.0060.59712.34
5.4.50.0110.68012.34
5.4.40.0070.63412.32
5.4.30.0100.52912.32
5.4.20.0060.49112.32
5.4.10.0080.49712.32
5.4.00.0120.51811.81
5.3.290.0060.03912.80
5.3.280.0080.03912.71
5.3.270.0060.05412.72
5.3.260.0090.05512.72
5.3.250.0090.05212.72
5.3.240.0100.03912.72
5.3.230.0190.07212.71
5.3.220.0080.05312.68
5.3.210.0110.04812.68
5.3.200.0070.06412.68
5.3.190.0100.04612.68
5.3.180.0080.04512.67
5.3.170.0080.03912.67
5.3.160.0090.06212.67
5.3.150.0060.05012.67
5.3.140.0090.04512.66
5.3.130.0160.06212.65
5.3.120.0060.04212.66
5.3.110.0090.04312.66
5.3.100.0080.04012.12
5.3.90.0050.05112.08
5.3.80.0150.04712.07
5.3.70.0060.05512.07
5.3.60.0210.08512.06
5.3.50.0220.06412.00
5.3.40.0120.07312.00
5.3.30.0190.07611.94
5.3.20.0160.09611.70
5.3.10.0070.07911.67
5.3.00.0120.12911.66
5.2.170.0110.0779.16
5.2.160.0120.0499.15
5.2.150.0080.0589.15
5.2.140.0140.0749.15
5.2.130.0080.0439.11
5.2.120.0080.0459.11
5.2.110.0040.0399.12
5.2.100.0090.0469.12
5.2.90.0120.0539.11
5.2.80.0100.0409.11
5.2.70.0110.0289.11
5.2.60.0060.0319.06
5.2.50.0070.0309.03
5.2.40.0090.0349.01
5.2.30.0070.0508.98
5.2.20.0080.0448.98
5.2.10.0050.0448.90
5.2.00.0110.0538.77
5.1.60.0100.0298.05
5.1.50.0180.1008.05
5.1.40.0060.0418.03
5.1.30.0120.0488.38
5.1.20.0050.0448.40
5.1.10.0060.0368.13
5.1.00.0120.0628.13
5.0.50.0040.0296.60
5.0.40.0060.0266.46
5.0.30.0040.0426.27
5.0.20.0060.0276.24
5.0.10.0050.0276.22
5.0.00.0060.0416.21
4.4.90.0070.0184.78
4.4.80.0040.0224.76
4.4.70.0050.0214.75
4.4.60.0040.0214.75
4.4.50.0030.0314.77
4.4.40.0040.0354.70
4.4.30.0000.0274.76
4.4.20.0060.0254.84
4.4.10.0050.0274.85
4.4.00.0060.0344.75
4.3.110.0050.0264.67
4.3.100.0070.0224.66
4.3.90.0030.0264.63
4.3.80.0020.0384.58
4.3.70.0080.0364.63
4.3.60.0060.0194.63
4.3.50.0050.0224.63
4.3.40.0050.0324.54
4.3.30.0030.0223.27
4.3.20.0030.0223.25
4.3.10.0020.0283.21
4.3.00.0030.0209.32

preferences:
50.54 ms | 401 KiB | 5 Q