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); } $diffOld = microtime(1) - $start; echo "Old time: $diffOld\n"; // Simple benchmark for NEW alpha2gd conversion $start = microtime(1); foreach (range(0,1,1/1000) as $input) { convertNew($input); } $diffNew = microtime(1) - $start; echo "New time: $diffNew\n"; echo (($diffOld-$diffNew)/$diffOld*100)."% faster\n"; // Iterate through a whole bunch of floats // to ensure OLD output matches NEW output $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.2.00.0030.03319.28
7.1.70.0000.03317.21
7.1.60.0070.06019.40
7.1.50.0070.05716.96
7.1.00.0070.10322.32
7.0.200.0000.02816.75
7.0.140.0070.10322.15
7.0.60.0100.09720.10
7.0.50.0200.04018.19
7.0.40.0000.10020.40
7.0.30.0200.06020.25
7.0.20.0330.09720.24
7.0.10.0030.07020.23
7.0.00.0100.07320.09
5.6.280.0130.24022.45
5.6.210.0100.20721.77
5.6.200.0100.22019.48
5.6.190.0170.23321.60
5.6.180.0270.18021.76
5.6.170.0100.18321.73
5.6.160.0130.23321.62
5.6.150.0030.17719.39
5.6.140.0530.17319.28
5.6.130.0100.21719.45
5.6.120.0130.19722.29
5.6.110.0130.22022.28
5.6.100.0070.22022.29
5.6.90.0000.21022.40
5.6.80.0030.23321.68
5.5.350.0300.21321.73
5.5.340.0100.21319.25
5.5.330.0170.23321.59
5.5.320.0370.21321.54
5.5.310.0330.21321.41
5.5.300.0070.24719.29
5.5.290.0030.17019.23
5.5.280.0170.23322.18
5.5.270.0030.23721.97
5.5.260.0170.22722.16
5.5.250.0130.18722.08
5.5.240.0130.22021.59
5.4.450.1000.24720.71
5.4.440.0570.26020.83
5.4.430.0630.26720.68
5.4.420.0630.26020.64
5.4.410.0070.26020.29
5.4.400.0470.31020.11
5.4.390.0330.27320.04
5.4.380.0130.25719.88
5.4.370.0030.31019.96
5.4.360.0100.31319.77
5.4.350.0100.19413.31
5.4.340.0040.19513.31
5.4.320.0110.18913.80
5.4.310.0080.19113.80
5.4.300.0090.18113.80
5.4.290.0060.19813.79
5.4.280.0060.20213.69
5.4.270.0050.19613.69
5.4.260.0060.19313.69
5.4.250.0080.21213.70
5.4.240.0070.20513.69
5.4.230.0070.20213.69
5.4.220.0060.19513.68
5.4.210.0040.19513.68
5.4.200.0050.19613.68
5.4.190.0090.20013.68
5.4.180.0020.19213.68
5.4.170.0050.19113.69
5.4.160.0060.18913.68
5.4.150.0070.19013.68
5.4.140.0050.19213.36
5.4.130.0050.20013.35
5.4.120.0040.19513.31
5.4.110.0120.19113.30
5.4.100.0070.18913.30
5.4.90.0090.19613.30
5.4.80.0060.19013.30
5.4.70.0080.18413.30
5.4.60.0080.18213.30
5.4.50.0110.18413.30
5.4.40.0060.19313.29
5.4.30.0080.20313.29
5.4.20.0080.20013.29
5.4.10.0070.20813.29
5.4.00.0080.19012.77
5.3.290.0090.19514.16
5.3.280.0070.19414.09
5.3.270.0100.19514.10
5.3.260.0090.19214.11
5.3.250.0060.19714.10
5.3.240.0040.20514.16
5.3.230.0070.20914.09
5.3.220.0100.19814.06
5.3.210.0110.20814.07
5.3.200.0070.21314.06
5.3.190.0090.20814.07
5.3.180.0100.19914.07
5.3.170.0100.19714.06
5.3.160.0060.20914.07
5.3.150.0090.21314.06
5.3.140.0080.22314.05
5.3.130.0080.20414.04
5.3.120.0070.19914.05
5.3.110.0050.20114.04
5.3.100.0080.20313.54
5.3.90.0090.22013.52
5.3.80.0060.19713.51
5.3.70.0070.19213.50
5.3.60.0040.20613.49
5.3.50.0120.19013.44
5.3.40.0070.20313.51
5.3.30.0080.21613.41
5.3.20.0100.21813.18
5.3.10.0100.21213.15
5.3.00.0040.20013.13
5.2.170.0060.23210.56
5.2.160.0050.23010.56
5.2.150.0080.24410.56
5.2.140.0070.22210.56
5.2.130.0110.23910.52
5.2.120.0080.22410.52
5.2.110.0100.21910.52
5.2.100.0020.23910.52
5.2.90.0100.21710.52
5.2.80.0060.23210.51
5.2.70.0060.23210.51
5.2.60.0080.22010.46
5.2.50.0100.22810.44
5.2.40.0060.22410.41
5.2.30.0030.22410.29
5.2.20.0070.21910.29
5.2.10.0080.23010.19
5.2.00.0080.22410.06
5.1.60.0100.2299.86
5.1.50.0060.2199.85
5.1.40.0050.2229.83
5.1.30.0050.22010.18
5.1.20.0040.21510.20
5.1.10.0020.2179.93
5.1.00.0060.2279.93
5.0.50.0060.4848.41
5.0.40.0040.4498.27
5.0.30.0040.4978.08
5.0.20.0040.4638.05
5.0.10.0030.4348.03
5.0.00.0040.4578.02
4.4.90.0040.0174.78
4.4.80.0030.0154.75
4.4.70.0060.0234.75
4.4.60.0040.0264.76
4.4.50.0050.0254.77
4.4.40.0060.0414.71
4.4.30.0150.0194.76
4.4.20.0070.0324.85
4.4.10.0070.0194.85
4.4.00.0080.0304.76
4.3.110.0040.0164.66
4.3.100.0020.0164.67
4.3.90.0020.0174.64
4.3.80.0030.0364.61
4.3.70.0050.0214.63
4.3.60.0020.0164.63
4.3.50.0030.0234.62
4.3.40.0030.0244.56
4.3.30.0070.0163.36
4.3.20.0060.0153.34
4.3.10.0030.0153.30
4.3.00.0070.0277.20

preferences:
36.94 ms | 401 KiB | 5 Q