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', ]; 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.0200.03918.43
8.3.50.0240.01921.27
8.3.40.0230.00619.12
8.3.30.0140.02420.42
8.3.20.0100.01320.59
8.3.10.0140.00721.21
8.3.00.0070.00722.44
8.2.180.0220.03218.66
8.2.170.0250.02122.96
8.2.160.0260.01922.46
8.2.150.0030.01924.18
8.2.140.0160.00824.66
8.2.130.0000.01626.16
8.2.120.0040.01420.94
8.2.110.0160.01021.29
8.2.100.0100.01018.41
8.2.90.0130.00719.34
8.2.80.0090.00317.97
8.2.70.0000.01217.75
8.2.60.0140.00718.16
8.2.50.0060.01218.10
8.2.40.0040.01218.59
8.2.30.0080.00419.77
8.2.20.0100.00318.01
8.2.10.0030.01618.12
8.2.00.0070.00518.00
8.1.280.0270.02725.92
8.1.270.0070.01323.99
8.1.260.0060.00626.35
8.1.250.0160.00628.09
8.1.240.0190.00922.87
8.1.230.0150.00920.38
8.1.220.0040.01818.04
8.1.210.0040.01118.77
8.1.200.0100.01317.47
8.1.190.0000.01417.47
8.1.180.0070.00718.10
8.1.170.0170.00718.79
8.1.160.0060.00919.10
8.1.150.0070.00718.89
8.1.140.0030.01017.74
8.1.130.0070.01418.04
8.1.120.0070.01417.66
8.1.110.0080.01117.55
8.1.100.0030.01017.61
8.1.90.0000.02117.75
8.1.80.0040.00717.77
8.1.70.0070.01417.68
8.1.60.0120.00317.75
8.1.50.0000.02317.82
8.1.40.0000.01417.69
8.1.30.0040.01817.84
8.1.20.0040.01117.88
8.1.10.0030.01317.86
8.1.00.0040.01217.65
8.0.300.0070.00718.77
8.0.290.0060.01516.75
8.0.280.0100.00318.59
8.0.270.0030.01017.45
8.0.260.0060.00916.98
8.0.250.0060.00917.01
8.0.240.0070.01017.05
8.0.230.0070.00416.89
8.0.220.0060.00616.87
8.0.210.0060.00616.86
8.0.200.0060.01317.06
8.0.190.0000.01416.99
8.0.180.0090.01217.10
8.0.170.0040.01416.91
8.0.160.0000.01317.09
8.0.150.0110.01116.89
8.0.140.0060.01316.93
8.0.130.0110.01413.57
8.0.120.0030.01016.88
8.0.110.0080.01216.98
8.0.100.0090.00917.05
8.0.90.0090.00416.84
8.0.80.0140.03416.94
8.0.70.0000.02117.01
8.0.60.0070.00716.92
8.0.50.0000.01316.87
8.0.30.0410.04217.27
8.0.20.0410.04017.40
8.0.10.0030.01717.11
8.0.00.0320.04316.84
7.4.330.0040.01516.93
7.4.320.0030.01016.58
7.4.300.0110.01116.71
7.4.290.0030.01716.44
7.4.280.0090.01216.59
7.4.270.0000.01716.67
7.4.260.0070.01313.45
7.4.250.0090.00616.56
7.4.240.0020.01616.67
7.4.230.0100.01616.69
7.4.220.0340.05816.56
7.4.210.0080.03416.70
7.4.200.0030.01016.78
7.4.190.0030.01416.86
7.4.160.0370.04316.79
7.4.150.0410.04117.40
7.4.140.0330.04217.86
7.4.130.0400.05516.81
7.4.120.0340.03516.52
7.4.110.0600.08416.56
7.4.100.0720.05716.73
7.4.90.0200.02416.67
7.4.80.0350.06019.39
7.4.70.0330.03416.56
7.4.60.0130.04416.52
7.4.50.0070.01316.55
7.4.40.0070.02222.77
7.4.30.0300.05016.74
7.3.330.0030.01513.55
7.3.320.0070.01813.61
7.3.310.0130.01016.50
7.3.300.0030.01416.58
7.3.290.0130.04816.45
7.3.280.0230.02416.47
7.3.270.0470.04217.40
7.3.260.0330.04618.24
7.3.250.0430.03916.63
7.3.240.0510.05716.73
7.3.230.0260.04116.69
7.3.210.0380.02216.81
7.3.200.0660.07919.39
7.3.190.0260.02516.65
7.3.180.0190.03516.41
7.3.170.0160.05216.42
7.3.160.0670.05016.64
7.2.330.0390.04916.77
7.2.320.0300.07916.83
7.2.310.0370.05916.75
7.2.300.0140.05116.89
7.2.290.0370.05216.92
7.2.100.1280.02515.00
7.2.90.1060.02814.80
7.2.80.1200.02115.02
7.2.70.1950.01315.27
7.2.60.1860.01915.14
7.2.50.1240.02415.20
7.2.40.0630.03014.98
7.2.30.0140.02315.20
7.2.20.1780.02215.25
7.2.10.0730.01715.08
7.2.00.0280.03415.07
7.1.220.0330.02814.11
7.1.210.1800.02414.18
7.1.200.0180.03714.00
7.1.190.1280.01814.04
7.1.180.0280.02614.13
7.1.170.0520.02813.91
7.1.160.0710.03713.66
7.1.150.0750.03814.01
7.1.140.0140.02413.99
7.1.130.0340.02514.07
7.1.120.1090.02413.64
7.1.110.0660.03014.00
7.1.100.0490.04614.08
7.1.90.0240.02213.84
7.1.80.0290.02913.92
7.1.70.0940.03513.95
7.1.60.0580.03831.95
7.1.50.0840.02332.18
7.1.40.0810.04532.33
7.1.30.1460.04032.32
7.1.20.0830.03532.32
7.1.10.0360.01813.92
7.1.00.0250.02814.14
7.0.310.1580.04113.57
7.0.300.0840.01213.45
7.0.290.0800.00913.52
7.0.280.0430.03413.45
7.0.270.0650.03413.71
7.0.260.0470.03513.52
7.0.250.0750.01913.79
7.0.240.0450.02013.75
7.0.230.0790.03613.60
7.0.220.0750.04813.62
7.0.210.0170.03713.92
7.0.200.0680.03813.75
7.0.190.0410.02713.84
7.0.180.0180.03013.61
7.0.170.0310.00913.92
7.0.160.0190.03113.64
7.0.150.0210.03113.77
7.0.140.0890.01213.65
7.0.130.0840.02313.76
7.0.120.1400.02013.64
7.0.110.1140.02613.61
7.0.100.0440.02813.74
7.0.90.0230.01613.76
7.0.80.0150.03113.56
7.0.70.1230.03013.76
7.0.60.0420.01113.45
7.0.50.1060.03413.75
7.0.40.0280.02513.83
7.0.30.0220.03213.93
7.0.20.0260.02813.78
7.0.10.0600.03313.89
7.0.00.0240.01213.79
5.6.380.0190.04214.39
5.6.370.0150.04614.78
5.6.360.0180.04014.53
5.6.350.0150.05514.49
5.6.340.0230.04614.76
5.6.330.0120.06514.40
5.6.320.0220.03614.46
5.6.310.0400.06314.81
5.6.300.0090.06214.82
5.6.290.0240.04614.61
5.6.280.0200.05914.75
5.6.270.0150.05214.63
5.6.260.0180.05214.75
5.6.250.0120.04914.44
5.6.240.0300.03914.89
5.6.230.0240.04514.81
5.6.220.0100.02714.81
5.6.210.0090.05914.67
5.6.200.0290.05214.44
5.6.190.0140.04914.71
5.6.180.0240.03814.77
5.6.170.0150.02414.91
5.6.160.0170.04814.34
5.6.150.0200.04314.46
5.6.140.0330.03714.70
5.6.130.0170.05414.64
5.6.120.0110.04314.47
5.6.110.0230.05914.83
5.6.100.0210.02214.59
5.6.90.0140.04014.51
5.6.80.0250.04114.79
5.6.70.0240.06914.69
5.6.60.0190.04814.43
5.6.50.0090.05314.36
5.6.40.0100.04814.35
5.6.30.0200.05614.53
5.6.20.0250.05414.60
5.6.10.0410.03614.71
5.6.00.0230.02614.39
5.5.380.0200.02813.45
5.5.370.0190.02413.45
5.5.360.0090.02813.45
5.5.350.0260.03413.45
5.5.340.0210.04513.45
5.5.330.0110.04913.45
5.5.320.0310.03413.45
5.5.310.0130.04913.45
5.5.300.0130.05013.45
5.5.290.0220.05113.45
5.5.280.0040.06313.45
5.5.270.0310.04613.45
5.5.260.0080.04113.45
5.5.250.0170.02013.45
5.5.240.0070.03313.45
5.5.230.0120.04613.45
5.5.220.0150.05113.45
5.5.210.0260.03013.45
5.5.200.0050.05713.45
5.5.190.0220.05613.45
5.5.180.0270.03013.45
5.5.170.0180.05814.65
5.5.160.0210.04513.45
5.5.150.0160.04813.45
5.4.450.0200.04113.45
5.4.440.0320.03213.45
5.4.430.0230.05013.45
5.4.420.0120.03413.45
5.4.410.0340.03313.45
5.4.400.0150.03113.45
5.4.390.0090.05113.45
5.4.380.0330.02113.45
5.4.370.0040.03613.45
5.4.360.0140.06113.45
5.4.350.0120.03913.45
5.4.340.0230.03413.45
5.4.330.0140.01913.45
5.4.320.0200.04813.45
5.4.310.0110.05713.45
5.3.290.0080.00013.45

preferences:
55.22 ms | 401 KiB | 5 Q