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', ]; for ( $i=0; $i<count($hotels); $i++ ) { $hotels[$i][4] = 0; } $starCoefOptions = range(0.02, 2, 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.0160.03218.43
8.3.50.0200.03321.27
8.3.40.0270.01318.81
8.3.30.0130.01620.45
8.3.20.0090.00920.37
8.3.10.0310.00721.29
8.3.00.0120.00322.52
8.2.180.0160.02318.54
8.2.170.0220.02522.96
8.2.160.0130.01022.37
8.2.150.0030.02424.18
8.2.140.0090.00324.66
8.2.130.0110.01126.16
8.2.120.0160.00621.00
8.2.110.0120.01221.19
8.2.100.0180.00718.03
8.2.90.0060.00919.30
8.2.80.0000.01318.02
8.2.70.0000.01417.62
8.2.60.0060.01518.05
8.2.50.0060.01918.07
8.2.40.0030.01718.30
8.2.30.0080.01119.76
8.2.20.0040.01118.00
8.2.10.0060.00617.91
8.2.00.0000.01418.00
8.1.280.0230.02025.92
8.1.270.0070.01123.99
8.1.260.0110.00426.35
8.1.250.0070.01028.09
8.1.240.0100.01024.04
8.1.230.0310.01518.08
8.1.220.0030.01218.77
8.1.210.0090.00620.85
8.1.200.0160.01017.60
8.1.190.0110.01117.78
8.1.180.0060.01018.10
8.1.170.0070.00718.71
8.1.160.0030.01019.20
8.1.150.0030.01718.91
8.1.140.0060.00917.74
8.1.130.0000.01318.12
8.1.120.0030.01017.81
8.1.110.0060.00617.73
8.1.100.0030.01017.72
8.1.90.0030.01317.73
8.1.80.0000.01617.78
8.1.70.0040.00817.69
8.1.60.0070.01717.91
8.1.50.0070.00717.80
8.1.40.0100.00317.79
8.1.30.0070.01417.86
8.1.20.0110.00317.79
8.1.10.0000.01417.76
8.1.00.0060.01117.77
8.0.300.0000.01120.04
8.0.290.0030.01017.28
8.0.280.0170.00718.54
8.0.270.0000.01717.41
8.0.260.0000.01116.81
8.0.250.0030.01017.03
8.0.240.0100.01316.98
8.0.230.0070.00717.01
8.0.220.0030.01216.98
8.0.210.0040.01116.97
8.0.200.0030.00917.05
8.0.190.0100.01317.02
8.0.180.0070.01116.97
8.0.170.0070.00716.99
8.0.160.0060.00717.09
8.0.150.0070.02117.01
8.0.140.0080.00616.89
8.0.130.0040.01113.62
8.0.120.0140.00416.99
8.0.110.0140.00716.99
8.0.100.0000.02117.04
8.0.90.0030.01016.92
8.0.80.0130.03317.04
8.0.70.0030.01016.97
8.0.60.0030.01617.05
8.0.50.0000.01416.84
8.0.30.0330.03917.27
8.0.20.0350.05417.40
8.0.10.0000.01317.23
8.0.00.0340.05716.74
7.4.330.0000.01215.12
7.4.320.0000.01216.59
7.4.300.0040.00816.68
7.4.290.0030.01016.51
7.4.280.0060.00616.54
7.4.270.0030.00916.70
7.4.260.0030.00913.52
7.4.250.0060.00916.63
7.4.240.0050.01316.63
7.4.230.0070.00716.80
7.4.220.0180.04716.56
7.4.210.0150.03316.65
7.4.200.0070.01416.48
7.4.190.0080.01916.50
7.4.160.0420.02916.65
7.4.150.0080.03617.40
7.4.140.0260.04017.86
7.4.130.0470.03916.71
7.4.120.0330.04716.62
7.4.110.0470.03716.55
7.4.100.0250.04416.68
7.4.90.0440.05816.54
7.4.80.0370.03719.39
7.4.70.0130.02416.62
7.4.60.0200.03016.66
7.4.50.0100.01016.56
7.4.40.0130.05722.77
7.4.30.0230.04216.70
7.3.330.0040.01513.47
7.3.320.0030.01213.55
7.3.310.0030.01016.72
7.3.300.0030.01716.44
7.3.290.0130.05816.43
7.3.280.0330.03916.48
7.3.270.0280.04017.40
7.3.260.0300.04418.24
7.3.250.0380.04116.69
7.3.240.0360.04816.51
7.3.230.0150.05916.77
7.3.210.0270.02016.84
7.3.200.0170.05419.39
7.3.190.0130.02916.61
7.3.180.0530.03716.29
7.3.170.0310.04416.70
7.3.160.0590.04016.63
7.2.330.0100.03217.03
7.2.320.0210.04216.98
7.2.310.0370.04416.97
7.2.300.0150.02416.66
7.2.290.0290.03517.04
7.2.100.0800.01515.01
7.2.90.0420.02715.03
7.2.80.1160.01115.03
7.2.70.0910.02115.30
7.2.60.0670.02715.31
7.2.50.0930.01415.11
7.2.40.1000.02415.27
7.2.30.1360.02714.79
7.2.20.0690.03315.00
7.2.10.0460.03914.57
7.2.00.0720.03314.89
7.1.220.0880.02413.73
7.1.210.0760.03614.02
7.1.200.0810.02914.02
7.1.190.0730.01214.01
7.1.180.0160.03214.04
7.1.170.0960.04213.93
7.1.160.0880.03013.80
7.1.150.0890.02214.02
7.1.140.0430.02913.84
7.1.130.0690.05113.75
7.1.120.1520.02013.65
7.1.110.0630.04114.07
7.1.100.0630.03313.82
7.1.90.0730.01313.93
7.1.80.0500.02813.94
7.1.70.0780.02613.79
7.1.60.0980.03532.22
7.1.50.0770.02732.38
7.1.40.0840.03331.93
7.1.30.0640.02931.90
7.1.20.1850.04032.32
7.1.10.1040.03714.10
7.1.00.0250.02813.79
7.0.310.1340.02913.59
7.0.300.0800.03813.59
7.0.290.0880.01313.63
7.0.280.0990.03613.59
7.0.270.0590.04213.59
7.0.260.1280.03113.59
7.0.250.0690.02513.59
7.0.240.0660.01413.71
7.0.230.0630.02013.59
7.0.220.0690.03413.72
7.0.210.0720.02513.64
7.0.200.1000.03113.80
7.0.190.0620.02014.01
7.0.180.0250.02213.73
7.0.170.0580.02613.59
7.0.160.0250.02413.87
7.0.150.0280.02913.68
7.0.140.0230.03113.82
7.0.130.0900.04213.79
7.0.120.0760.02013.72
7.0.110.0930.01413.59
7.0.100.0200.05313.87
7.0.90.0730.02413.92
7.0.80.0810.02513.74
7.0.70.1060.02913.80
7.0.60.0880.01913.64
7.0.50.0970.02313.97
7.0.40.0590.02913.81
7.0.30.0270.02313.81
7.0.20.1060.03013.77
7.0.10.0310.02813.84
7.0.00.0190.00913.95
5.6.380.0140.05414.68
5.6.370.0220.03414.53
5.6.360.0150.02914.42
5.6.350.0340.02314.78
5.6.340.0160.05414.87
5.6.330.0100.03214.76
5.6.320.0260.04614.79
5.6.310.0190.03114.61
5.6.300.0290.03214.56
5.6.290.0180.04014.58
5.6.280.0320.04214.88
5.6.270.0300.03814.77
5.6.260.0270.04514.64
5.6.250.0240.04814.60
5.6.240.0130.03114.71
5.6.230.0190.05114.72
5.6.220.0110.02814.51
5.6.210.0290.03214.93
5.6.200.0230.03214.50
5.6.190.0210.03714.68
5.6.180.0310.02814.38
5.6.170.0120.05614.55
5.6.160.0250.03114.89
5.6.150.0210.06414.46
5.6.140.0210.03814.47
5.6.130.0060.03314.54
5.6.120.0110.06014.58
5.6.110.0290.02514.58
5.6.100.0130.02314.83
5.6.90.0170.04114.63
5.6.80.0210.03914.47
5.6.70.0210.05414.67
5.6.60.0130.05014.57
5.6.50.0170.05714.79
5.6.40.0200.04014.66
5.6.30.0200.03614.16
5.6.20.0180.03614.57
5.6.10.0140.05614.43
5.6.00.0220.04214.35
5.5.380.0110.03813.59
5.5.370.0100.06213.59
5.5.360.0220.04413.59
5.5.350.0270.03313.59
5.5.340.0190.03713.59
5.5.330.0100.03513.59
5.5.320.0270.04113.59
5.5.310.0030.05913.59
5.5.300.0190.03313.59
5.5.290.0260.05413.59
5.5.280.0080.04413.59
5.5.270.0240.04813.59
5.5.260.0080.04213.59
5.5.250.0030.03713.59
5.5.240.0090.05313.59
5.5.230.0150.03013.59
5.5.220.0160.04413.59
5.5.210.0210.07813.59
5.5.200.0030.04913.59
5.5.190.0090.02913.59
5.5.180.0130.03613.59
5.5.170.0140.06414.73
5.5.160.0210.03113.59
5.5.150.0230.04613.59
5.4.450.0250.03813.59
5.4.440.0120.02213.59
5.4.430.0090.04713.59
5.4.420.0030.04413.59
5.4.410.0190.04113.59
5.4.400.0110.05013.59
5.4.390.0180.04313.59
5.4.380.0130.05113.59
5.4.370.0180.06313.59
5.4.360.0180.06613.59
5.4.350.0210.03413.59
5.4.340.0160.02813.59
5.4.330.0340.03113.59
5.4.320.0030.04413.59
5.4.310.0330.03313.59
5.3.290.0050.00513.59

preferences:
54.79 ms | 401 KiB | 5 Q