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', 'Chaba', 'Ya', ]; for ( $i=0; $i<count($hotels); $i++ ) { $hotels[$i][4] = 0; } $starCoefOptions = range(0.1, 5, 0.1); $ratingCoefOptions = range(20, 10000, 20); 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.0100.11518.77
8.3.50.0100.11521.21
8.3.40.0160.09218.77
8.3.30.0030.10620.59
8.3.20.0030.05520.30
8.3.10.0060.05222.17
8.3.00.0000.05722.52
8.2.180.0100.13116.75
8.2.170.0100.11822.96
8.2.160.0100.10520.64
8.2.150.0030.06124.18
8.2.140.0030.05524.66
8.2.130.0070.05626.16
8.2.120.0100.04820.93
8.2.110.0030.10520.60
8.2.100.0030.09418.03
8.2.90.0000.08919.38
8.2.80.0030.08319.41
8.2.70.0030.09417.88
8.2.60.0030.08618.05
8.2.50.0030.09718.07
8.2.40.0000.08718.40
8.2.30.0000.08319.57
8.2.20.0060.08117.84
8.2.10.0000.09018.03
8.2.00.0000.09917.84
8.1.280.0100.10525.92
8.1.270.0030.05323.99
8.1.260.0100.04926.35
8.1.250.0070.04928.09
8.1.240.0030.10424.03
8.1.230.0070.08122.23
8.1.220.0030.08717.74
8.1.210.0000.08718.77
8.1.200.0070.08317.35
8.1.190.0000.08717.76
8.1.180.0030.08618.10
8.1.170.0000.08418.67
8.1.160.0000.08719.12
8.1.150.0000.08918.79
8.1.140.0030.08417.58
8.1.130.0000.08418.05
8.1.120.0030.08617.64
8.1.110.0000.08717.55
8.1.100.0030.09017.60
8.1.90.0000.08717.58
8.1.80.0000.08717.67
8.1.70.0030.08517.64
8.1.60.0030.11017.86
8.1.50.0070.10517.72
8.1.40.0030.12317.70
8.1.30.0000.11117.76
8.1.20.0000.11117.77
8.1.10.0070.10317.86
8.1.00.0070.10517.60
8.0.300.0070.08018.77
8.0.290.0030.08517.40
8.0.280.0030.08418.56
8.0.270.0030.08417.46
8.0.260.0030.08617.02
8.0.250.0000.08617.14
8.0.240.0030.10317.21
8.0.230.0030.08417.07
8.0.220.0060.08117.13
8.0.210.0000.08717.11
8.0.200.0000.09017.12
8.0.190.0070.10217.06
8.0.180.0030.10717.18
8.0.170.0000.11317.04
8.0.160.0070.10317.16
8.0.150.0030.10717.09
8.0.140.0000.11017.11
8.0.130.0000.11013.50
8.0.120.0030.10916.97
8.0.110.0070.10417.01
8.0.100.0000.10917.12
8.0.90.0000.11116.93
8.0.80.0130.17017.03
8.0.70.0030.10616.90
8.0.60.0030.10617.15
8.0.50.0030.10716.97
8.0.30.0060.16217.30
8.0.20.0130.14317.42
8.0.10.0030.10817.20
8.0.00.0130.15816.84
7.4.330.0000.08116.95
7.4.320.0030.08416.84
7.4.300.0000.08816.66
7.4.290.0070.10216.80
7.4.280.0000.10816.70
7.4.270.0030.10816.79
7.4.260.0000.10713.43
7.4.250.0030.10616.69
7.4.240.0050.10516.76
7.4.230.0070.11516.75
7.4.220.0130.17116.68
7.4.210.0040.14516.72
7.4.200.0030.10616.46
7.4.190.0070.10516.88
7.4.160.0160.13116.69
7.4.150.0100.19017.40
7.4.140.0110.13717.86
7.4.130.0120.15416.79
7.4.120.0100.14316.72
7.4.110.0100.14816.70
7.4.100.0130.14116.69
7.4.90.0100.16316.82
7.4.80.0070.16819.39
7.4.70.0130.14616.73
7.4.60.0070.14216.73
7.4.50.0100.08116.42
7.4.40.0160.14822.77
7.4.30.0060.15316.79
7.4.00.0100.16115.59
7.3.330.0030.10213.63
7.3.320.0000.10813.56
7.3.310.0030.10316.58
7.3.300.0030.10316.49
7.3.290.0130.13216.55
7.3.280.0090.17416.57
7.3.270.0130.14717.40
7.3.260.0130.15316.72
7.3.250.0100.15516.76
7.3.240.0160.24216.82
7.3.230.0130.13716.67
7.3.210.0100.15616.66
7.3.200.0090.19319.39
7.3.190.0070.15516.87
7.3.180.0130.15016.67
7.3.170.0000.15816.59
7.3.160.0070.14316.76
7.3.120.0070.17715.16
7.3.110.0030.23715.18
7.3.100.0100.17115.11
7.3.90.0030.17615.04
7.3.80.0070.18615.09
7.3.70.0070.19915.29
7.3.60.0030.19815.17
7.3.50.0070.20215.31
7.3.40.0070.16115.28
7.3.30.0030.16115.05
7.3.20.0070.18216.89
7.3.10.0070.20816.97
7.3.00.0070.15317.00
7.2.330.0100.14717.10
7.2.320.0260.25616.99
7.2.310.0130.23716.88
7.2.300.0160.26516.99
7.2.290.0160.14916.85
7.2.250.0100.23715.48
7.2.240.0130.23415.46
7.2.230.0030.18915.05
7.2.220.0030.16115.27
7.2.210.0070.16715.49
7.2.200.0030.22115.50
7.2.190.0030.21915.48
7.2.180.0000.22915.40
7.2.170.0030.18815.44
7.2.160.0030.16515.23
7.2.150.0030.23317.09
7.2.140.0110.20417.01
7.2.130.0000.22117.23
7.2.120.0030.20717.30
7.2.110.0070.22917.24
7.2.100.0030.20817.23
7.2.90.0030.20017.34
7.2.80.0000.23717.05
7.2.70.0030.15917.16
7.2.60.0030.16517.30
7.2.50.0030.17217.29
7.2.40.0000.22517.30
7.2.30.0070.17117.00
7.2.20.0030.22917.30
7.2.10.0100.18617.13
7.2.00.0030.19117.30
7.1.330.0100.31516.07
7.1.320.0000.30516.30
7.1.310.0030.27816.23
7.1.300.0000.25416.27
7.1.290.0030.30515.80
7.1.280.0000.23815.91
7.1.270.0030.31016.25
7.1.260.0070.31116.14
7.1.250.0030.26715.91
7.1.240.0030.25016.02
7.1.230.0050.33816.29
7.1.220.0000.31616.06
7.1.210.0070.26316.06
7.1.200.0100.27016.00
7.1.190.0070.31416.16
7.1.180.0070.32916.21
7.1.170.0070.23916.30
7.1.160.0030.28815.99
7.1.150.0030.26116.02
7.1.140.0030.33516.18
7.1.130.0100.25816.03
7.1.120.0030.33616.06
7.1.110.0070.25116.10
7.1.100.0000.25416.17
7.1.90.0070.30616.16
7.1.80.0070.33016.15
7.1.70.0000.30016.23
7.1.60.0000.30216.18
7.1.50.0000.25716.26
7.1.40.0130.28415.97
7.1.30.0000.30416.03
7.1.20.0000.26115.88
7.1.10.0030.28316.22
7.1.00.0020.24319.45
7.0.330.0030.28615.67
7.0.320.0030.28115.80
7.0.310.0000.32515.81
7.0.300.0030.29815.78
7.0.290.0100.32015.78
7.0.280.0070.31315.77
7.0.270.0100.24615.56
7.0.260.0030.35415.64
7.0.250.0000.29715.68
7.0.240.0000.28315.49
7.0.230.0070.26815.65
7.0.220.0030.29815.55
7.0.210.0000.25715.61
7.0.200.0000.31215.48
7.0.190.0130.34915.64
7.0.180.0070.35815.80
7.0.170.0000.32915.92
7.0.160.0030.28315.55
7.0.150.0000.28115.67
7.0.140.0050.28919.27
7.0.130.0070.32715.73
7.0.120.0030.35715.69
7.0.110.0030.24615.63
7.0.100.0030.24915.87
7.0.90.0090.35415.61
7.0.80.0070.30915.72
7.0.70.0030.26815.75
7.0.60.0030.28715.82
7.0.50.0030.36815.92
7.0.40.0000.37813.75
7.0.30.0030.37013.47
7.0.20.0070.28013.94
7.0.10.0000.28813.61
7.0.00.0070.37213.78
5.6.400.0000.56515.04
5.6.390.0070.61814.75
5.6.380.0000.65615.06
5.6.370.0030.56715.05
5.6.360.0100.50114.43
5.6.350.0030.61515.05
5.6.340.0070.59414.52
5.6.330.0130.62114.79
5.6.320.0030.68615.02
5.6.310.0070.57814.77
5.6.300.0070.57914.90
5.6.290.0070.69614.96
5.6.280.0080.53118.28
5.6.270.0030.65615.05
5.6.260.0100.65614.69
5.6.250.0030.57414.88
5.6.240.0130.65314.78
5.6.230.0030.70914.85
5.6.220.0070.55214.82
5.6.210.0070.67315.00
5.6.200.0030.65114.89
5.6.190.0070.65014.92
5.6.180.0070.68014.71
5.6.170.0000.63114.85
5.6.160.0000.70514.91
5.6.150.0070.71014.69
5.6.140.0100.57514.86
5.6.130.0030.72314.95
5.6.120.0100.57514.82
5.6.110.0000.69914.83
5.6.100.0070.64014.89
5.6.90.0100.54415.07
5.6.80.0100.64514.44
5.6.70.0030.56914.65
5.6.60.0000.70714.85
5.6.50.0070.52414.99
5.6.40.0070.69814.49
5.6.30.0000.70314.77
5.6.20.0070.56514.52
5.6.10.0070.55114.87
5.6.00.0030.57114.76
5.5.380.0030.71614.83
5.5.370.0000.74214.56
5.5.360.0030.64514.45
5.5.350.0030.65614.94
5.5.340.0030.58014.97
5.5.330.0070.70114.74
5.5.320.0030.68714.77
5.5.310.0100.71614.84
5.5.300.0000.73214.92
5.5.290.0030.56314.68
5.5.280.0070.71414.50
5.5.270.0030.73114.95
5.5.260.0030.61714.71
5.5.250.0030.64914.30
5.5.240.0000.56714.54
5.5.230.0100.63814.87
5.5.220.0070.73214.90
5.5.210.0030.72014.85
5.5.200.0000.71714.78
5.5.190.0030.73414.81
5.5.180.0000.72315.15
5.5.170.0070.57314.54
5.5.160.0000.64614.50
5.5.150.0030.71514.60
5.5.140.0070.73715.02
5.5.130.0100.63714.58
5.5.120.0030.67314.52
5.5.110.0070.70314.65
5.5.100.0030.54614.50
5.5.90.0000.74814.66
5.5.80.0030.73014.67
5.5.70.0070.66514.59
5.5.60.0100.62714.56
5.5.50.0100.62314.91
5.5.40.0030.69514.83
5.5.30.0000.63414.75
5.5.20.0030.62514.89
5.5.10.0030.52814.73
5.5.00.0030.70414.75
5.4.450.0070.61111.48
5.4.440.0030.65811.84
5.4.430.0030.74211.48
5.4.420.0030.64711.85
5.4.410.0070.59711.66
5.4.400.0030.71411.48
5.4.390.0070.69711.51
5.4.380.0000.73911.60
5.4.370.0070.57911.48
5.4.360.0070.60111.48
5.4.350.0070.70311.51
5.4.340.0070.70011.48
5.4.330.0130.62511.48
5.4.320.0000.73911.50
5.4.310.0030.75311.48
5.4.300.0070.72611.49
5.4.290.0030.53111.60
5.4.280.0070.58815.43
5.4.270.0030.54515.46
5.4.260.0231.00712.15
5.4.250.0000.59011.48
5.4.240.0030.63011.71
5.4.230.0030.70511.48
5.4.220.0030.73411.70
5.4.210.0030.65511.48
5.4.200.0030.65911.48
5.4.190.0000.66511.48
5.4.180.0000.75211.48
5.4.170.0000.66611.48
5.4.160.0070.58111.59
5.4.150.0030.54811.48
5.4.140.0000.70011.61
5.4.130.0030.59711.72
5.4.120.0030.69511.55
5.4.110.0070.60111.51
5.4.100.0030.64811.55
5.4.90.0030.58611.48
5.4.80.0100.62911.70
5.4.70.0070.63311.55
5.4.60.0030.61711.86
5.4.50.0030.63511.48
5.4.40.0000.68711.56
5.4.30.0030.53111.71
5.4.20.0070.57611.64
5.4.10.0030.57711.48
5.4.00.0070.55211.65
5.3.290.0030.00311.48
5.3.280.0060.00311.48
5.3.270.0030.00311.48
5.3.260.0000.01111.48
5.3.250.0000.00711.48
5.3.240.0000.00711.48
5.3.230.0030.00311.48
5.3.220.0000.00711.48
5.3.210.0070.00711.48
5.3.200.0000.00611.48
5.3.190.0000.00711.48
5.3.180.0030.00311.48
5.3.170.0000.00711.48
5.3.160.0000.00711.48
5.3.150.0070.00011.48
5.3.140.0050.00311.48
5.3.130.0040.00411.48
5.3.120.0070.00011.48
5.3.110.0060.00011.48
5.3.100.0060.00311.48
5.3.90.0000.00611.48
5.3.80.0030.00311.48
5.3.70.0080.00011.48
5.3.60.0030.00311.48
5.3.50.0030.00311.48
5.3.40.0060.00011.48
5.3.30.0060.00311.48
5.3.20.0070.00311.48
5.3.10.0000.00411.48
5.3.00.0000.00511.48

preferences:
51.67 ms | 401 KiB | 5 Q