3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convertOld($input) { $oldMin = 0; $oldMax = 1; $newMin = 127; $newMax = 0; return ceil(((($input- $oldMin) * ($newMax - $newMin)) / ($oldMax - $oldMin)) + $newMin); } function convertNew($input) { $range_input = range(1, 0, 1/127); $range_output = range(0, 127); foreach ($range_input as $key => $value) { if ($value <= $input) { return $range_output[$key]; } } return 127; } $start = microtime(1); foreach (range(0,1,1/1000) as $input) { convertOld($input); } echo "Old time: ".(microtime(1) - $start)."\n"; $start = microtime(1); foreach (range(0,1,1/1000) as $input) { convertNew($input); } echo "New time: ".(microtime(1) - $start)."\n"; $warnings = array(); foreach (range(0,1,1/10000) as $input) { if (convertOld($input) != convertNew($input)) $warnings[] = $input; } if (count($warnings)) { echo "Warning, value mismatches at ".implode(", ", $warnings)."\n"; } else { echo "All values passed!\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)
7.4.10.0100.03315.34
7.4.00.0070.04615.08
7.3.130.0030.05215.18
7.3.120.0100.04415.10
7.3.110.0130.04215.33
7.3.100.0100.03015.42
7.3.90.0030.03415.16
7.3.80.0100.02915.05
7.3.70.0080.03415.09
7.3.60.0000.03715.10
7.3.50.0070.03715.24
7.3.40.0030.03615.19
7.3.30.0000.03715.04
7.3.20.0060.03616.68
7.3.10.0080.03216.71
7.3.00.0030.03416.63
7.2.260.0130.03715.19
7.2.250.0000.04815.39
7.2.240.0030.03615.33
7.2.230.0060.03915.54
7.2.220.0030.03715.57
7.2.210.0030.03415.62
7.2.200.0100.03315.44
7.2.190.0030.03615.32
7.2.180.0070.03315.59
7.2.170.0030.03715.23
7.2.160.0000.03715.27
7.2.150.0100.03016.88
7.2.140.0070.03816.89
7.2.130.0030.03516.96
7.2.120.0030.04116.85
7.2.110.0090.03216.74
7.2.100.0050.03416.87
7.2.90.0090.03116.89
7.2.80.0050.03316.90
7.2.70.0020.03716.95
7.2.60.0050.03816.99
7.2.50.0050.03816.91
7.2.40.0030.03417.11
7.2.30.0060.03517.00
7.2.20.0080.03416.81
7.2.10.0030.04016.96
7.2.00.0040.03017.75
7.1.330.0060.05215.82
7.1.320.0070.05315.78
7.1.310.0070.05115.86
7.1.300.0030.05215.75
7.1.290.0030.05415.87
7.1.280.0030.05015.84
7.1.270.0030.05315.77
7.1.260.0030.05715.74
7.1.250.0050.05015.83
7.1.240.0030.05415.89
7.1.230.0130.04515.46
7.1.220.0030.05116.02
7.1.210.0070.05015.77
7.1.200.0060.05215.83
7.1.190.0030.05415.63
7.1.180.0100.05015.62
7.1.170.0030.05115.90
7.1.160.0030.05415.78
7.1.150.0030.05915.69
7.1.140.0060.04815.71
7.1.130.0000.05915.68
7.1.120.0030.05115.71
7.1.110.0030.05515.73
7.1.100.0030.05316.04
7.1.90.0100.05215.91
7.1.80.0060.05216.01
7.1.70.0070.04416.47
7.1.60.0100.05317.55
7.1.50.0100.04416.50
7.1.40.0060.04815.71
7.1.30.0100.05115.75
7.1.20.0070.05315.93
7.1.10.0000.05515.73
7.1.00.0030.08319.02
7.0.330.0100.04715.25
7.0.320.0070.04815.59
7.0.310.0140.04415.28
7.0.300.0060.05415.44
7.0.290.0030.05415.61
7.0.280.0070.05215.11
7.0.270.0000.07615.33
7.0.260.0030.05315.33
7.0.250.0030.06915.50
7.0.240.0070.05015.61
7.0.230.0000.05715.49
7.0.220.0000.05615.44
7.0.210.0030.05115.31
7.0.200.0150.04315.27
7.0.190.0030.05915.23
7.0.180.0030.05615.64
7.0.170.0060.04815.32
7.0.160.0030.05315.40
7.0.150.0070.05315.22
7.0.140.0070.07818.74
7.0.130.0000.05115.53
7.0.120.0060.04715.50
7.0.110.0030.05215.44
7.0.100.0000.06015.55
7.0.90.0100.05015.11
7.0.80.0030.05115.17
7.0.70.0030.05615.32
7.0.60.0030.07818.01
7.0.50.0080.05516.97
7.0.40.0000.06116.62
7.0.30.0180.07916.90
7.0.20.0130.06216.86
7.0.10.0070.05316.83
7.0.00.0070.06316.94
5.6.400.0030.21915.60
5.6.390.0030.24415.51
5.6.380.0070.23315.95
5.6.370.0030.24015.77
5.6.360.0100.22615.73
5.6.350.0070.21315.70
5.6.340.0070.22515.56
5.6.330.0070.23715.63
5.6.320.0070.21815.63
5.6.310.0070.21515.86
5.6.300.0030.22415.60
5.6.290.0070.23416.00
5.6.280.0070.22718.75
5.6.270.0070.21015.71
5.6.260.0030.26115.46
5.6.250.0100.22015.68
5.6.240.0030.27515.59
5.6.230.0030.23715.90
5.6.220.0130.23615.68
5.6.210.0070.22418.91
5.6.200.0150.22217.45
5.6.190.0030.21918.68
5.6.180.0120.20418.68
5.6.170.0120.19518.65
5.6.160.0070.19118.74
5.6.150.0070.22117.55
5.6.140.0150.22417.69
5.6.130.0070.19517.64
5.6.120.0020.25718.91
5.6.110.0080.22518.96
5.6.100.0130.25219.05
5.6.90.0070.21919.08
5.6.80.0100.19918.67
5.6.70.0100.21115.38
5.6.60.0100.21815.70
5.6.50.0100.24315.59
5.6.40.0000.20715.29
5.6.30.0070.23215.50
5.6.20.0070.23915.77
5.6.10.0030.24515.65
5.6.00.0100.20315.64
5.5.380.0000.24415.55
5.5.370.0000.22415.92
5.5.360.0070.24515.68
5.5.350.0030.23918.51
5.5.340.0050.23917.48
5.5.330.0070.19918.52
5.5.320.0200.22818.51
5.5.310.0200.21618.59
5.5.300.0050.23417.36
5.5.290.0030.22817.33
5.5.280.0080.22118.91
5.5.270.0030.23118.79
5.5.260.0080.21618.87
5.5.250.0070.21718.78
5.5.240.0030.24818.57
5.5.230.0100.27415.12
5.5.220.0030.30015.33
5.5.210.0100.21215.39
5.5.200.0070.25315.32
5.5.190.0070.26915.79
5.5.180.0000.22815.65
5.5.170.0030.21615.39
5.5.160.0100.23415.53
5.5.150.0030.27015.14
5.5.140.0070.24815.72
5.5.130.0070.23315.70
5.5.120.0070.24815.63
5.5.110.0130.23115.59
5.5.100.0030.23915.39
5.5.90.0030.25415.70
5.5.80.0070.23715.29
5.5.70.0030.26415.28
5.5.60.0070.25015.14
5.5.50.0030.23815.45
5.5.40.0100.24015.30
5.5.30.0000.24715.43
5.5.20.0030.21415.22
5.5.10.0070.25615.42
5.5.00.0030.23815.32
5.4.450.0500.27516.36
5.4.440.0280.24516.66
5.4.430.0500.27516.56
5.4.420.0220.24916.64
5.4.410.0070.24316.45
5.4.400.0250.25516.24
5.4.390.0170.29016.38
5.4.380.0120.26116.23
5.4.370.0080.27516.16
5.4.360.0000.23316.22
5.4.350.0040.26012.85
5.4.340.0090.22512.96
5.4.330.0030.23612.34
5.4.320.0090.22313.04
5.4.310.0060.21613.08
5.4.300.0060.20713.02
5.4.290.0020.20512.97
5.4.280.0060.22913.15
5.4.270.0080.19912.90
5.4.260.0040.25413.13
5.4.250.0090.23112.99
5.4.240.0070.23113.01
5.4.230.0070.22012.90
5.4.220.0040.23913.14
5.4.210.0060.23112.94
5.4.200.0070.20612.90
5.4.190.0090.20913.00
5.4.180.0070.22112.88
5.4.170.0060.23713.05
5.4.160.0020.21613.03
5.4.150.0020.22812.97
5.4.140.0060.24212.85
5.4.130.0070.24513.00
5.4.120.0050.22612.72
5.4.110.0040.21512.85
5.4.100.0060.21212.92
5.4.90.0080.21812.88
5.4.80.0070.22512.87
5.4.70.0060.21712.83
5.4.60.0060.22612.90
5.4.50.0050.22312.80
5.4.40.0100.20112.80
5.4.30.0020.21012.88
5.4.20.0070.21912.66
5.4.10.0070.23412.82
5.4.00.0040.22812.63
5.3.290.0060.19014.16
5.3.280.0050.19514.09
5.3.270.0090.18714.17
5.3.260.0090.18914.10
5.3.250.0060.18814.10
5.3.240.0080.20314.10
5.3.230.0110.18814.09
5.3.220.0060.19014.06
5.3.210.0060.19314.06
5.3.200.0050.19514.12
5.3.190.0060.20014.06
5.3.180.0070.18514.06
5.3.170.0070.18914.05
5.3.160.0060.19014.06
5.3.150.0030.19414.06
5.3.140.0080.20014.05
5.3.130.0100.19214.04
5.3.120.0080.19114.04
5.3.110.0050.19414.05
5.3.100.0090.19913.54
5.3.90.0110.19913.52
5.3.80.0080.18613.51
5.3.70.0090.18913.51
5.3.60.0070.20013.49
5.3.50.0040.19113.44
5.3.40.0040.21513.44
5.3.30.0050.20213.40
5.3.20.0080.20613.18
5.3.10.0080.18913.14
5.3.00.0070.19113.13
5.2.170.0080.21110.56
5.2.160.0060.21110.56
5.2.150.0070.21310.55
5.2.140.0080.21310.55
5.2.130.0090.21610.51
5.2.120.0020.22310.52
5.2.110.0070.22310.52
5.2.100.0050.21910.51
5.2.90.0050.21210.52
5.2.80.0060.23410.50
5.2.70.0060.21710.50
5.2.60.0070.20310.46
5.2.50.0060.21510.43
5.2.40.0060.22110.41
5.2.30.0040.21310.29
5.2.20.0070.21810.44
5.2.10.0090.23010.35
5.2.00.0090.21810.05
5.1.60.0050.2079.85
5.1.50.0040.2139.85
5.1.40.0050.2309.82
5.1.30.0050.20610.17
5.1.20.0050.21610.20
5.1.10.0040.2129.93
5.1.00.0040.2139.93
5.0.50.0030.4678.41
5.0.40.0100.4428.27
5.0.30.0200.4548.08
5.0.20.0040.4458.04
5.0.10.0080.4298.02
5.0.00.0020.4568.02
4.4.90.0010.0174.78
4.4.80.0040.0144.76
4.4.70.0060.0124.76
4.4.60.0020.0164.75
4.4.50.0020.0164.77
4.4.40.0010.0274.71
4.4.30.0010.0174.76
4.4.20.0010.0174.84
4.4.10.0060.0124.84
4.4.00.0030.0244.76
4.3.110.0030.0154.67
4.3.100.0040.0154.67
4.3.90.0030.0144.63
4.3.80.0040.0234.61
4.3.70.0040.0174.63
4.3.60.0030.0154.63
4.3.50.0040.0144.63
4.3.40.0020.0244.55
4.3.30.0050.0143.36
4.3.20.0010.0173.34
4.3.10.0010.0163.30
4.3.00.0100.0237.20

preferences:
43.56 ms | 400 KiB | 5 Q