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.2, 0.3, 0.4, 0.5); $ratingCoefOptions = array(1000, 2000, 3000, 4000); 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.70.0060.00916.58
8.3.60.0190.00318.65
8.3.50.0100.00922.11
8.3.40.0040.01119.14
8.3.30.0100.01019.09
8.3.20.0000.00818.68
8.3.10.0040.00421.30
8.3.00.0080.00021.98
8.2.180.0090.00916.63
8.2.170.0180.00422.96
8.2.160.0070.00720.68
8.2.150.0030.00524.18
8.2.140.0000.00924.66
8.2.130.0030.00526.16
8.2.120.0070.00319.33
8.2.110.0070.00320.62
8.2.100.0120.00018.16
8.2.90.0050.00319.42
8.2.80.0000.00817.97
8.2.70.0000.00817.88
8.2.60.0040.00418.05
8.2.50.0040.00418.07
8.2.40.0050.00518.53
8.2.30.0050.00321.44
8.2.20.0050.00317.99
8.2.10.0030.00518.07
8.2.00.0060.00317.99
8.1.280.0180.00325.92
8.1.270.0050.00323.99
8.1.260.0060.00326.35
8.1.250.0080.00028.09
8.1.240.0030.00622.75
8.1.230.0090.00321.10
8.1.220.0000.00818.77
8.1.210.0000.00818.99
8.1.200.0060.00317.48
8.1.190.0030.00517.66
8.1.180.0040.00418.10
8.1.170.0030.00518.82
8.1.160.0070.00318.98
8.1.150.0080.00018.77
8.1.140.0040.00417.64
8.1.130.0050.00218.01
8.1.120.0000.00717.69
8.1.110.0040.00417.68
8.1.100.0040.00417.56
8.1.90.0080.00017.64
8.1.80.0040.00417.75
8.1.70.0020.00517.53
8.1.60.0030.00617.64
8.1.50.0040.00417.75
8.1.40.0030.00617.62
8.1.30.0040.00417.73
8.1.20.0080.00017.79
8.1.10.0030.00517.78
8.1.00.0000.00817.68
8.0.300.0040.00420.19
8.0.290.0030.00517.43
8.0.280.0000.00818.71
8.0.270.0030.00317.48
8.0.260.0000.00717.04
8.0.250.0060.00317.23
8.0.240.0000.00817.09
8.0.230.0070.00017.19
8.0.220.0000.00717.17
8.0.210.0000.00917.05
8.0.200.0040.00417.13
8.0.190.0080.00017.15
8.0.180.0040.00417.07
8.0.170.0000.00817.06
8.0.160.0000.00817.07
8.0.150.0040.00417.14
8.0.140.0000.00917.08
8.0.130.0060.00013.55
8.0.120.0040.00417.05
8.0.110.0030.00516.95
8.0.100.0040.00416.89
8.0.90.0000.00816.97
8.0.80.0060.01617.00
8.0.70.0070.00017.13
8.0.60.0000.00917.13
8.0.50.0030.00517.09
8.0.30.0110.01417.36
8.0.20.0120.01217.40
8.0.10.0050.00317.30
8.0.00.0070.01217.07
7.4.330.0060.00016.83
7.4.320.0000.00616.84
7.4.300.0030.00316.72
7.4.290.0070.00016.75
7.4.280.0030.00316.86
7.4.270.0030.00316.74
7.4.260.0050.00013.45
7.4.250.0000.00816.76
7.4.240.0030.00316.66
7.4.230.0050.00216.90
7.4.220.0150.00616.64
7.4.210.0070.00816.80
7.4.200.0040.00416.65
7.4.190.0000.00816.98
7.4.160.0160.00716.80
7.4.150.0080.01217.40
7.4.140.0120.00817.86
7.4.130.0140.00816.82
7.4.120.0140.00616.88
7.4.110.0040.01616.86
7.4.100.0110.00816.90
7.4.90.0080.01316.63
7.4.80.0140.00819.39
7.4.70.0090.00916.79
7.4.60.0120.00616.71
7.4.50.0060.00016.56
7.4.40.0100.00722.77
7.4.30.0160.00516.83
7.4.00.0070.01015.35
7.3.330.0050.00013.40
7.3.320.0030.00313.42
7.3.310.0030.00316.55
7.3.300.0070.00016.58
7.3.290.0130.00316.52
7.3.280.0110.00816.58
7.3.270.0090.01217.40
7.3.260.0090.01418.24
7.3.250.0140.00616.60
7.3.240.0090.00916.56
7.3.230.0070.01116.49
7.3.210.0100.01016.56
7.3.200.0130.00519.39
7.3.190.0060.01216.80
7.3.180.0100.01016.64
7.3.170.0170.00616.64
7.3.160.0060.01416.53
7.3.120.0130.00615.36
7.3.110.0070.00715.37
7.3.100.0100.00315.27
7.3.90.0030.01015.04
7.3.80.0100.00315.46
7.3.70.0000.01715.05
7.3.60.0070.01015.38
7.3.50.0100.00315.26
7.3.40.0060.00915.24
7.3.30.0100.00315.17
7.3.20.0080.00817.11
7.3.10.0040.00716.94
7.3.00.0000.01317.07
7.2.330.0150.00317.02
7.2.320.0120.01217.08
7.2.310.0090.01216.71
7.2.300.0150.00616.75
7.2.290.0110.00716.95
7.2.240.0040.00815.44
7.2.230.0070.00715.32
7.2.220.0060.00615.38
7.2.210.0030.01015.38
7.2.200.0090.00615.54
7.2.190.0100.00715.36
7.2.180.0090.00615.34
7.2.170.0060.00915.55
7.2.160.0040.01115.38
7.2.150.0040.01117.32
7.2.140.0140.00317.28
7.2.130.0090.00617.35
7.2.120.0070.00717.26
7.2.110.0090.00617.21
7.2.100.0120.00617.14
7.2.90.0070.00717.18
7.2.80.0150.00317.27
7.2.70.0000.01217.27
7.2.60.0030.01017.53
7.2.50.0060.00917.39
7.2.40.0040.01117.41
7.2.30.0080.00417.39
7.2.20.0090.00617.46
7.2.10.0070.00717.36
7.2.00.0120.00418.54
7.1.330.0030.01015.86
7.1.320.0060.00916.11
7.1.310.0030.01515.91
7.1.300.0060.01215.87
7.1.290.0140.00016.13
7.1.280.0060.01216.33
7.1.270.0000.01416.05
7.1.260.0000.01416.12
7.1.250.0030.01315.94
7.1.100.0070.00718.26
7.1.70.0030.00617.38
7.1.60.0070.01019.40
7.1.50.0060.00917.36
7.1.00.0000.05322.66
7.0.200.0030.00516.89
7.0.140.0030.07722.23
7.0.100.0330.06720.35
7.0.90.0300.05020.48
7.0.80.0100.04320.32
7.0.70.0300.04720.21
7.0.60.0100.07020.38
7.0.50.0100.03320.73
7.0.40.0170.07720.40
7.0.30.0100.07320.39
7.0.20.0030.07020.34
7.0.10.0130.07320.46
7.0.00.0100.05320.38
5.6.280.0030.07721.40
5.6.250.0030.05321.00
5.6.240.0230.07020.91
5.6.230.0070.06720.80
5.6.220.0130.06320.95
5.6.210.0130.07320.98
5.6.200.0100.07021.48
5.6.190.0070.08721.34
5.6.180.0030.08021.34
5.6.170.0070.04721.42
5.6.160.0130.04021.34
5.6.150.0030.04721.36
5.6.140.0100.04021.39
5.6.130.0070.05321.31
5.6.120.0030.04721.36
5.6.110.0170.03021.33
5.6.100.0070.04021.33
5.6.90.0100.03721.46
5.6.80.0100.04020.78
5.6.70.0030.03320.73
5.6.60.0100.06320.81
5.6.50.0030.04020.73
5.6.40.0030.03320.71
5.6.30.0030.04020.79
5.6.20.0000.04720.73
5.6.10.0070.03320.78
5.6.00.0030.03320.73
5.5.380.0030.06020.84
5.5.370.0030.09320.77
5.5.360.0100.07320.83
5.5.350.0070.08020.64
5.5.340.0070.09021.31
5.5.330.0030.08321.07
5.5.320.0030.04021.14
5.5.310.0100.06321.20
5.5.300.0070.03721.20
5.5.290.0030.04321.21
5.5.280.0100.04721.11
5.5.270.0030.04321.10
5.5.260.0030.04021.13
5.5.250.0070.04320.93
5.5.240.0000.03720.56
5.5.230.0070.03020.60
5.5.220.0070.05020.57
5.5.210.0030.04020.59
5.5.200.0030.04320.57
5.5.190.0100.03320.46
5.5.180.0100.03720.49
5.5.160.0070.03720.54
5.5.150.0100.03020.46
5.5.140.0100.03320.54
5.5.130.0030.04020.46
5.5.120.0000.04320.53
5.5.110.0030.04020.56
5.5.100.0030.04320.45
5.5.90.0000.04020.44
5.5.80.0030.04020.36
5.5.70.0000.04320.36
5.5.60.0000.03720.35
5.5.50.0030.04320.46
5.5.40.0070.03320.24
5.5.30.0070.03320.36
5.5.20.0030.03320.39
5.5.10.0030.03320.43
5.5.00.0000.03720.36
5.4.450.0070.04019.63
5.4.440.0030.04019.51
5.4.430.0070.04319.79
5.4.420.0070.03719.62
5.4.410.0030.03319.54
5.4.400.0000.03319.29
5.4.390.0030.03019.28
5.4.380.0000.04319.43
5.4.370.0070.03719.37
5.4.360.0030.04019.47
5.4.350.0070.03719.16
5.4.340.0070.04019.20
5.4.320.0170.02719.47
5.4.310.0070.03719.39
5.4.300.0070.05319.37
5.4.290.0030.04319.34
5.4.280.0030.04019.48
5.4.270.0030.03719.28
5.4.260.0000.03319.41
5.4.250.0130.02719.15
5.4.240.0030.03319.19
5.4.230.0070.03319.42
5.4.220.0000.04019.15
5.4.210.0000.03319.29
5.4.200.0000.03319.36
5.4.190.0000.03319.46
5.4.180.0070.03019.36
5.4.170.0130.03019.36
5.4.160.0100.03719.17
5.4.150.0070.05719.32
5.4.140.0130.06716.62
5.4.130.0030.07716.77
5.4.120.0130.07016.74
5.4.110.0030.04316.73
5.4.100.0030.08016.81
5.4.90.0100.08316.70
5.4.80.0170.06016.76
5.4.70.0100.05716.76
5.4.60.0070.07316.78
5.4.50.0000.07316.71
5.4.40.0100.06316.70
5.4.30.0070.04716.77
5.4.20.0070.07316.74
5.4.10.0130.07716.74
5.4.00.0030.05316.19
5.3.290.0000.04315.74
5.3.280.0000.04015.74
5.3.270.0000.03315.74
5.3.260.0000.03315.74
5.3.250.0030.03715.74
5.3.240.0030.08015.74
5.3.230.0030.04715.74
5.3.220.0030.04715.74
5.3.210.0100.07015.74
5.3.200.0170.06315.74
5.3.190.0070.04715.74
5.3.180.0100.07015.74
5.3.170.0070.05715.74
5.3.160.0000.07315.74
5.3.150.0100.06015.74
5.3.140.0170.03315.74
5.3.130.0000.07715.74
5.3.120.0000.08015.74
5.3.110.0100.07015.74
5.3.100.0030.06715.74
5.3.90.0030.07715.74
5.3.80.0170.07015.74
5.3.70.0070.07715.74
5.3.60.0130.06715.74
5.3.50.0030.06015.74
5.3.40.0100.06715.74
5.3.30.0130.06715.74
5.3.20.0100.07015.74
5.3.10.0030.07315.74
5.3.00.0170.06015.74
5.2.170.0070.05315.74
5.2.160.0070.06315.74
5.2.150.0100.04715.74
5.2.140.0070.04015.74
5.2.130.0070.06015.74
5.2.120.0170.05015.74
5.2.110.0030.04015.74
5.2.100.0070.06015.74
5.2.90.0000.03715.74
5.2.80.0000.07015.74
5.2.70.0130.04715.74
5.2.60.0070.05715.74
5.2.50.0030.05015.74
5.2.40.0000.03015.74
5.2.30.0100.05715.74
5.2.20.0070.04315.74
5.2.10.0030.03715.74
5.2.00.0030.06315.74
5.1.60.0000.04315.74
5.1.50.0070.03315.74
5.1.40.0070.02715.74
5.1.30.0070.05015.74
5.1.20.0100.05015.74
5.1.10.0070.05315.74
5.1.00.0100.02315.74
5.0.50.0030.02015.74
5.0.40.0030.02015.74
5.0.30.0030.03015.74
5.0.20.0000.04715.74
5.0.10.0070.04315.74
5.0.00.0070.03015.74
4.4.90.0030.03315.74
4.4.80.0000.02715.74
4.4.70.0000.02015.74
4.4.60.0070.02715.74
4.4.50.0000.03315.74
4.4.40.0000.06015.74
4.4.30.0030.01715.74
4.4.20.0000.02015.74
4.4.10.0000.01715.74
4.4.00.0030.03315.74
4.3.110.0030.01315.74
4.3.100.0030.02315.74
4.3.90.0030.03015.74
4.3.80.0000.03715.74
4.3.70.0000.01715.74
4.3.60.0000.01715.74
4.3.50.0070.03015.74
4.3.40.0030.03015.74
4.3.30.0070.03315.74
4.3.20.0000.03715.74
4.3.10.0070.02315.74
4.3.00.0000.03315.74

preferences:
58.03 ms | 401 KiB | 5 Q