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.7, 6950], ['Chaba', 3, 8.2, 7120], ]; $totalHotelsNumber = 2; $starCoef = 0.2; $ratingCoef = 2000; for ( $i=0; $i<count($hotels); $i++ ) { $hotels[$i][4] = 0; } for ( $i=0; $i<count($hotels); $i++ ) { for ( $j=$i+1; $j<count($hotels); $j++ ) { echo 'Comparing '.$hotels[$i][0].' and '.$hotels[$j][0].'...'."\r\n"; $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 = $hotels[$i][3]-$priceToCompensate; echo $price.' VS '.$hotels[$j][3]."\r\n"; if ( $price > $hotels[$j][3] ) { echo $hotels[$i][0].' wins!'."\r\n"; $hotels[$i][4]++; } else { echo $hotels[$j][0].' wins!'."\r\n"; $hotels[$j][4]++; } echo "\r\n".'----------'."\r\n"; } } usort($hotels, function($hotelA, $hotelB){ return $hotelB[4]-$hotelA[4]; }); echo "\r\n".'----------'."\r\n"; echo 'Top:'."\r\n\r\n"; for ( $i=0; $i<count($hotels); $i++ ) { echo $hotels[$i][0].': '.$hotels[$i][4]."\r\n"; } echo "\r\n".'----------'."\r\n"; echo 'Finalists:'."\r\n\r\n"; for ( $i=0; $i<=1; $i++ ) { echo $hotels[$i][0]."\r\n"; }

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.0150.00618.53
8.3.50.0100.00721.92
8.3.40.0060.00918.79
8.3.30.0070.01318.63
8.3.20.0030.00518.85
8.3.10.0050.00320.61
8.3.00.0040.00421.96
8.2.180.0120.00316.63
8.2.170.0120.00322.96
8.2.160.0090.00620.52
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0060.00326.16
8.2.120.0080.00019.48
8.2.110.0050.00519.45
8.2.100.0040.00817.84
8.2.90.0000.00817.63
8.2.80.0050.00318.73
8.2.70.0000.00817.50
8.2.60.0030.00617.63
8.2.50.0090.00018.10
8.2.40.0050.00320.60
8.2.30.0040.00419.85
8.2.20.0050.00317.64
8.2.10.0080.00017.79
8.2.00.0080.00017.69
8.1.280.0040.01125.92
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00719.26
8.1.230.0040.00720.96
8.1.220.0060.00318.57
8.1.210.0040.00418.77
8.1.200.0060.00317.47
8.1.190.0040.00417.52
8.1.180.0000.00818.10
8.1.170.0060.00318.46
8.1.160.0050.00318.98
8.1.150.0000.00818.60
8.1.140.0030.00517.39
8.1.130.0000.00717.86
8.1.120.0030.00517.42
8.1.110.0040.00417.40
8.1.100.0040.00417.52
8.1.90.0060.00317.52
8.1.80.0050.00317.52
8.1.70.0080.00017.39
8.1.60.0040.00417.55
8.1.50.0000.00917.60
8.1.40.0080.00017.40
8.1.30.0030.00617.65
8.1.20.0030.00617.69
8.1.10.0030.00517.59
8.1.00.0040.00417.44
8.0.300.0070.00018.77
8.0.290.0000.00817.00
8.0.280.0000.00818.38
8.0.270.0030.00317.33
8.0.260.0000.00716.76
8.0.250.0000.00716.96
8.0.240.0000.00817.04
8.0.230.0070.00016.98
8.0.220.0000.00716.92
8.0.210.0030.00516.81
8.0.200.0030.00616.98
8.0.190.0040.00417.06
8.0.180.0030.00516.85
8.0.170.0070.00016.91
8.0.160.0040.00416.83
8.0.150.0000.00816.90
8.0.140.0040.00416.79
8.0.130.0030.00613.34
8.0.120.0000.00816.93
8.0.110.0030.00616.91
8.0.100.0000.00716.71
8.0.90.0000.00716.81
8.0.80.0060.00916.94
8.0.70.0040.00416.83
8.0.60.0040.00417.01
8.0.50.0040.00416.80
8.0.30.0090.01117.20
8.0.20.0080.01017.40
8.0.10.0050.00217.05
8.0.00.0140.00816.85
7.4.330.0030.00314.83
7.4.320.0030.00516.53
7.4.300.0000.00616.57
7.4.290.0050.00316.64
7.4.280.0040.00416.56
7.4.270.0060.00316.66
7.4.260.0030.00313.19
7.4.250.0000.00716.61
7.4.240.0040.00416.60
7.4.230.0040.00416.74
7.4.220.0060.01116.71
7.4.210.0070.00816.64
7.4.200.0030.00316.65
7.4.190.0040.00416.50
7.4.160.0060.01216.61
7.4.150.0030.01417.40
7.4.140.0070.01117.86
7.4.130.0120.00616.55
7.4.120.0140.00516.55
7.4.110.0090.00916.80
7.4.100.0090.00916.56
7.4.90.0090.01216.59
7.4.80.0130.00419.37
7.4.70.0100.00716.53
7.4.60.0110.01016.56
7.4.50.0030.00316.68
7.4.40.0080.00822.27
7.4.30.0100.01316.55
7.4.00.0000.01214.99
7.3.330.0050.00013.47
7.3.320.0050.00013.23
7.3.310.0000.00716.38
7.3.300.0030.00516.36
7.3.290.0120.00416.39
7.3.280.0130.00316.43
7.3.270.0180.00017.40
7.3.260.0080.01018.24
7.3.250.0120.00716.54
7.3.240.0000.01616.49
7.3.230.0050.01416.63
7.3.210.0070.01116.55
7.3.200.0040.01519.39
7.3.190.0160.00316.67
7.3.180.0160.00616.53
7.3.170.0100.00716.34
7.3.160.0100.00716.55
7.3.120.0030.01214.99
7.2.330.0090.01416.66
7.2.320.0110.00616.47
7.2.310.0030.01516.79
7.2.300.0090.01616.88
7.2.290.0060.01116.62
7.2.00.0120.00319.46
7.1.100.0030.01017.97
7.1.70.0080.00317.23
7.1.60.0000.02419.40
7.1.50.0070.01617.11
7.1.00.0100.03322.44
7.0.200.0030.00716.87
7.0.140.0170.06022.21
7.0.60.0130.06720.08
7.0.50.0030.07017.76
7.0.40.0070.08020.02
7.0.30.0200.06720.07
7.0.20.0230.04020.33
7.0.10.0070.07320.19
7.0.00.0000.08020.23
5.6.280.0030.07020.88
5.6.210.0130.07720.49
5.6.200.0030.05318.29
5.6.190.0070.09320.48
5.6.180.4100.04020.39
5.6.170.0230.04020.54
5.6.160.0130.08020.44
5.6.150.0030.08318.24
5.6.140.0130.05318.15
5.6.130.0070.07318.25
5.6.120.0030.08021.15
5.6.110.0000.09320.96
5.6.100.0130.06720.98
5.6.90.0070.05021.02
5.6.80.0100.08020.54
5.5.350.0070.06020.39
5.5.340.0070.03717.93
5.5.330.0100.06720.57
5.5.320.0370.07320.20
5.5.310.0330.07020.30
5.5.300.0100.05317.94
5.5.290.0100.07317.95
5.5.280.0100.08320.67
5.5.270.0100.08020.96
5.5.260.0070.07020.89
5.5.250.0130.06020.73
5.5.240.0200.07320.29
5.4.450.3430.03719.39
5.4.440.3430.04019.48
5.4.430.3530.04019.43
5.4.420.3600.04019.20
5.4.410.3330.03319.28
5.4.400.3330.04318.99
5.4.390.3500.04019.31
5.4.380.3270.04018.98
5.4.370.3770.04319.09
5.4.360.3430.03318.85
5.4.350.3530.03719.20
5.4.340.3330.04019.25
5.4.320.3230.03719.24
5.4.310.3330.04719.06
5.4.300.2100.03718.98
5.4.290.3200.02719.22
5.4.280.2900.03318.83
5.4.270.2830.03719.22
5.4.260.3270.04019.31
5.4.250.3630.03719.09
5.4.240.3370.03318.94
5.4.230.3230.04019.17
5.4.220.3530.04018.86
5.4.210.3270.03718.82
5.4.200.3230.04319.08
5.4.190.3430.04318.96
5.4.180.3830.02319.22
5.4.170.3530.03319.30
5.4.160.3170.03719.07
5.4.150.3170.04018.83
5.4.140.3230.03316.39
5.4.130.3630.03716.66
5.4.120.3630.03716.52
5.4.110.3300.03316.50
5.4.100.3400.03716.54
5.4.90.3300.03716.29
5.4.80.2230.04016.55
5.4.70.2570.03316.45
5.4.60.2330.02716.51
5.4.50.2930.04316.17
5.4.40.3470.03016.43
5.4.30.3300.04016.42
5.4.20.3600.03316.26
5.4.10.4270.03716.25
5.4.00.3830.03015.73
5.3.290.3230.04014.62
5.3.280.3270.04014.54
5.3.270.3570.03714.55
5.3.260.3230.03714.59
5.3.250.3400.03314.45
5.3.240.3330.04014.55
5.3.230.3370.03714.47
5.3.220.3670.03714.41
5.3.210.3170.03314.46
5.3.200.2630.04014.45
5.3.190.2900.03714.52
5.3.180.2630.03314.42
5.3.170.2700.04014.42
5.3.160.2730.03014.41
5.3.150.3100.03314.41
5.3.140.2730.04314.60
5.3.130.3830.04014.50
5.3.120.3570.02714.49
5.3.110.3930.04014.50
5.3.100.4300.02714.00
5.3.90.3970.03313.97
5.3.80.3300.03313.96
5.3.70.3530.03313.92
5.3.60.3230.03713.84
5.3.50.3470.04013.82
5.3.40.3430.04013.79
5.3.30.4470.03713.78
5.3.20.3300.03313.64
5.3.10.3500.03313.45
5.3.00.2970.03313.49
5.2.170.3170.03010.99
5.2.160.3170.03311.19
5.2.150.3000.03011.00
5.2.140.3070.02311.23
5.2.130.3000.02711.25
5.2.120.2900.02710.95
5.2.110.2970.03010.94
5.2.100.3030.03010.95
5.2.90.3030.02711.20
5.2.80.3030.02711.19
5.2.70.3100.02710.95
5.2.60.2970.02311.05
5.2.50.2870.02710.87
5.2.40.2470.02710.84
5.2.30.2170.03010.82
5.2.20.2570.03010.96
5.2.10.2870.02710.80
5.2.00.2700.02710.81
5.1.60.2600.02310.11
5.1.50.2530.0279.86
5.1.40.2830.0209.85
5.1.30.2600.02310.25
5.1.20.2970.02310.34
5.1.10.2600.02310.04
5.1.00.2570.02710.00
5.0.50.1400.0178.45
5.0.40.1230.0208.32
5.0.30.1230.0378.21
5.0.20.1470.0208.26
5.0.10.1300.0208.25
5.0.00.1230.0338.04
4.4.90.1130.0137.41
4.4.80.1070.0177.41
4.4.70.1270.0177.41
4.4.60.1170.0177.41
4.4.50.1500.0177.41
4.4.40.1530.0277.41
4.4.30.1370.0137.41
4.4.20.1670.0107.41
4.4.10.1600.0177.41
4.4.00.1400.0237.41
4.3.110.1400.0137.41
4.3.100.1030.0177.41
4.3.90.1330.0177.41
4.3.80.1300.0237.41
4.3.70.1330.0207.41
4.3.60.1530.0177.41
4.3.50.1470.0207.41
4.3.40.1330.0307.41
4.3.30.0630.0207.41
4.3.20.0770.0237.41
4.3.10.0830.0207.41
4.3.00.0770.0207.41

preferences:
53.19 ms | 401 KiB | 5 Q