3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convertNew($input) { $oldMin = 0; $oldMax = 1; $newMin = 127; $newMax = 0; return ceil(((($input- $oldMin) * ($newMax - $newMin)) / ($oldMax - $oldMin)) + $newMin); } function convertOld($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; } // Simple benchmark for OLD alpha2gd conversion $start = microtime(1); foreach (range(0,1,1/1000) as $input) { convertOld($input); } echo "Old time: ".(microtime(1) - $start)."\n"; // Simple benchmark for NEW alpha2gd conversion $start = microtime(1); foreach (range(0,1,1/1000) as $input) { convertNew($input); } echo "New time: ".(microtime(1) - $start)."\n"; // Iterate through a whole bunch of floats $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.00.0030.04815.21
7.3.120.0070.04014.99
7.3.110.0070.04615.32
7.3.100.0060.03915.39
7.3.90.0100.02915.03
7.3.80.0030.03815.10
7.3.70.0030.03614.95
7.3.60.0030.03915.35
7.3.50.0030.03314.95
7.3.40.0100.02914.98
7.3.30.0000.04015.25
7.3.20.0070.03216.68
7.3.10.0090.03116.52
7.3.00.0000.03416.51
7.2.250.0100.04515.19
7.2.240.0000.05715.62
7.2.230.0030.03815.39
7.2.220.0130.02815.55
7.2.210.0070.03515.68
7.2.200.0070.03115.43
7.2.190.0030.03315.29
7.2.180.0060.03615.25
7.2.170.0000.04215.17
7.2.00.0030.02719.03
7.1.330.0070.05415.97
7.1.320.0070.05015.52
7.1.310.0030.06815.76
7.1.300.0030.05515.80
7.1.290.0040.05315.89
7.1.280.0100.04515.86
7.1.270.0030.05516.03
7.1.260.0030.05415.63
7.1.70.0030.02617.16
7.1.60.0100.05819.40
7.1.50.0070.03316.68
7.1.00.0030.11022.41
7.0.200.0370.02716.71
7.0.140.0030.11022.09
7.0.60.0170.10020.36
7.0.50.0130.10718.21
7.0.40.0100.05720.09
7.0.30.0200.06320.23
7.0.20.0330.10320.34
7.0.10.0230.08720.09
7.0.00.0100.10720.24
5.6.280.0070.24722.27
5.6.210.0070.23021.91
5.6.200.0070.18019.48
5.6.190.0000.17321.64
5.6.180.0230.17321.64
5.6.170.0100.22721.63
5.6.160.0200.19021.72
5.6.150.0070.16719.43
5.6.140.0100.20719.43
5.6.130.0030.21719.38
5.6.120.0130.22722.30
5.6.110.0100.21722.23
5.6.100.0130.23322.38
5.6.90.0100.18722.40
5.6.80.0000.16721.75
5.5.350.0100.16321.68
5.5.340.0030.17019.29
5.5.330.0100.23721.31
5.5.320.0100.17721.46
5.5.310.0330.19321.49
5.5.300.0100.23319.29
5.5.290.0070.24719.29
5.5.280.0170.23322.26
5.5.270.0000.19021.98
5.5.260.0000.27722.15
5.5.250.0130.21321.94
5.5.240.0070.24021.37
5.4.450.0630.27320.93
5.4.440.0570.28020.70
5.4.430.0330.24720.55
5.4.420.0500.25720.71
5.4.410.0070.25020.29
5.4.400.0330.27020.02
5.4.390.0330.27320.06
5.4.380.0100.25319.88
5.4.370.0130.25319.86
5.4.360.0030.29719.84
5.4.350.0090.18813.30
5.4.340.0080.19813.31
5.4.320.0050.18713.79
5.4.310.0060.18613.79
5.4.300.0070.18413.79
5.4.290.0060.18713.79
5.4.280.0050.19713.69
5.4.270.0080.19113.68
5.4.260.0100.19213.69
5.4.250.0100.19813.69
5.4.240.0080.20213.69
5.4.230.0100.18413.68
5.4.220.0030.18813.68
5.4.210.0050.18613.68
5.4.200.0030.19213.68
5.4.190.0060.19113.68
5.4.180.0060.19213.67
5.4.170.0070.18813.68
5.4.160.0040.19113.68
5.4.150.0070.18413.68
5.4.140.0040.18813.36
5.4.130.0050.19513.35
5.4.120.0030.19713.31
5.4.110.0080.18913.30
5.4.100.0070.18913.30
5.4.90.0060.19513.30
5.4.80.0090.18713.30
5.4.70.0080.18513.30
5.4.60.0040.18813.30
5.4.50.0100.18813.30
5.4.40.0060.19113.29
5.4.30.0050.19513.29
5.4.20.0070.19113.28
5.4.10.0050.19313.29
5.4.00.0070.18912.77
5.3.290.0110.18414.16
5.3.280.0080.19114.09
5.3.270.0080.19614.11
5.3.260.0080.19414.10
5.3.250.0120.18014.10
5.3.240.0060.19114.10
5.3.230.0040.19414.09
5.3.220.0060.19414.06
5.3.210.0080.19614.06
5.3.200.0040.19714.05
5.3.190.0100.19514.06
5.3.180.0070.19214.06
5.3.170.0060.19214.06
5.3.160.0080.18714.06
5.3.150.0070.19114.06
5.3.140.0070.19114.05
5.3.130.0060.19614.11
5.3.120.0040.19714.04
5.3.110.0080.19314.04
5.3.100.0070.20313.53
5.3.90.0100.20113.52
5.3.80.0100.21213.50
5.3.70.0070.19013.51
5.3.60.0060.19713.49
5.3.50.0070.19113.50
5.3.40.0080.19613.44
5.3.30.0050.20813.40
5.3.20.0060.20913.18
5.3.10.0050.19913.14
5.3.00.0050.19713.13
5.2.170.0060.22110.56
5.2.160.0040.23310.56
5.2.150.0040.21710.62
5.2.140.0040.22010.55
5.2.130.0020.21710.52
5.2.120.0050.22110.52
5.2.110.0050.22410.52
5.2.100.0040.21710.51
5.2.90.0050.21810.52
5.2.80.0070.21210.50
5.2.70.0040.21710.50
5.2.60.0050.21010.46
5.2.50.0070.21710.43
5.2.40.0100.21310.41
5.2.30.0030.21910.45
5.2.20.0060.21010.29
5.2.10.0040.22410.19
5.2.00.0050.21410.05
5.1.60.0060.2089.86
5.1.50.0040.2109.85
5.1.40.0060.2069.83
5.1.30.0040.20710.18
5.1.20.0060.21410.19
5.1.10.0050.2379.93
5.1.00.0030.2099.93
5.0.50.0050.4558.40
5.0.40.0060.4388.27
5.0.30.0040.5208.08
5.0.20.0050.4418.04
5.0.10.0030.4368.02
5.0.00.0040.4528.02
4.4.90.0030.0154.78
4.4.80.0010.0164.75
4.4.70.0040.0134.76
4.4.60.0010.0164.76
4.4.50.0010.0174.77
4.4.40.0030.0254.71
4.4.30.0040.0144.76
4.4.20.0010.0164.84
4.4.10.0030.0144.84
4.4.00.0020.0254.76
4.3.110.0030.0154.67
4.3.100.0050.0124.67
4.3.90.0040.0134.63
4.3.80.0040.0234.60
4.3.70.0020.0144.63
4.3.60.0010.0164.63
4.3.50.0030.0154.62
4.3.40.0040.0224.55
4.3.30.0010.0163.36
4.3.20.0020.0163.34
4.3.10.0010.0163.30
4.3.00.0200.0207.20

preferences:
32.89 ms | 401 KiB | 5 Q