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 $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.0100.03815.35
7.3.120.0070.04715.42
7.3.110.0070.04215.16
7.3.100.0070.03315.05
7.3.90.0050.03615.20
7.3.80.0020.03914.95
7.3.70.0060.03215.28
7.3.60.0050.03315.08
7.3.50.0020.03815.10
7.3.40.0030.03815.09
7.3.30.0030.03515.09
7.3.20.0030.03916.85
7.3.10.0030.03316.60
7.3.00.0030.03516.74
7.2.250.0070.04815.28
7.2.240.0050.05115.47
7.2.230.0120.03315.31
7.2.220.0100.03015.40
7.2.210.0030.03315.53
7.2.200.0100.02815.29
7.2.190.0050.03715.41
7.2.180.0080.03615.53
7.2.170.0070.03415.42
7.2.00.0060.03219.38
7.1.330.0030.05615.87
7.1.320.0060.05115.88
7.1.310.0100.04515.96
7.1.300.0030.05415.83
7.1.290.0050.05215.78
7.1.280.0020.05215.77
7.1.270.0020.05615.85
7.1.260.0020.05515.73
7.1.70.0040.02516.93
7.1.60.0100.05919.40
7.1.50.0070.03317.08
7.1.00.0100.10322.24
7.0.200.0060.02516.84
7.0.140.0030.10722.00
7.0.60.0100.10720.28
7.0.50.0000.09318.07
7.0.40.0030.07720.27
7.0.30.0270.07720.33
7.0.20.0270.10020.07
7.0.10.0030.10720.20
7.0.00.0100.10720.20
5.6.280.0030.25022.43
5.6.210.0100.22321.90
5.6.200.0100.22319.29
5.6.190.0100.23021.64
5.6.180.0230.22321.69
5.6.170.0230.21721.62
5.6.160.0170.22721.72
5.6.150.0100.23319.53
5.6.140.0000.20319.48
5.6.130.0030.22019.45
5.6.120.0000.24722.32
5.6.110.0070.17322.31
5.6.100.0030.22022.29
5.6.90.0170.23022.29
5.6.80.0070.16321.59
5.5.350.0300.20021.62
5.5.340.0030.20719.33
5.5.330.0070.17721.56
5.5.320.0230.21721.43
5.5.310.0300.20721.50
5.5.300.0000.19019.25
5.5.290.0030.19319.29
5.5.280.0100.24022.26
5.5.270.0030.17022.10
5.5.260.0130.24022.19
5.5.250.0200.23322.07
5.5.240.0000.22021.43
5.4.450.0700.26320.74
5.4.440.0730.33320.69
5.4.430.0730.24020.85
5.4.420.0700.26720.55
5.4.410.0030.26720.30
5.4.400.0330.26320.10
5.4.390.0270.25720.07
5.4.380.0170.25719.80
5.4.370.0070.24319.86
5.4.360.0000.21019.86
5.4.350.0100.22313.31
5.4.340.0090.19813.31
5.4.320.0090.18813.80
5.4.310.0060.18613.80
5.4.300.0090.18713.80
5.4.290.0100.18913.79
5.4.280.0050.19413.69
5.4.270.0050.19113.69
5.4.260.0050.19913.69
5.4.250.0040.19813.69
5.4.240.0070.20313.69
5.4.230.0050.19313.68
5.4.220.0110.18613.68
5.4.210.0050.18813.69
5.4.200.0050.19213.69
5.4.190.0050.19313.68
5.4.180.0040.19613.68
5.4.170.0050.19013.69
5.4.160.0090.19113.68
5.4.150.0050.18213.68
5.4.140.0090.18413.36
5.4.130.0050.19013.35
5.4.120.0050.20713.31
5.4.110.0070.19713.30
5.4.100.0070.19413.30
5.4.90.0070.19713.30
5.4.80.0120.18313.30
5.4.70.0120.18413.30
5.4.60.0070.18513.30
5.4.50.0070.19113.30
5.4.40.0030.19813.29
5.4.30.0050.19813.29
5.4.20.0060.19213.29
5.4.10.0080.19913.29
5.4.00.0090.18712.77
5.3.290.0040.19814.16
5.3.280.0070.18914.09
5.3.270.0100.19314.10
5.3.260.0050.19614.11
5.3.250.0040.19614.11
5.3.240.0100.19514.11
5.3.230.0080.19114.10
5.3.220.0070.19214.07
5.3.210.0090.18614.07
5.3.200.0070.18814.06
5.3.190.0080.19614.07
5.3.180.0080.20914.06
5.3.170.0050.19514.07
5.3.160.0050.19514.06
5.3.150.0060.18814.07
5.3.140.0080.19114.05
5.3.130.0070.20014.04
5.3.120.0050.22414.04
5.3.110.0090.28714.04
5.3.100.0060.20113.54
5.3.90.0060.19613.52
5.3.80.0070.20013.51
5.3.70.0080.19513.58
5.3.60.0060.20813.49
5.3.50.0060.19513.44
5.3.40.0050.20413.44
5.3.30.0050.22213.40
5.3.20.0060.20813.18
5.3.10.0080.20413.15
5.3.00.0090.21613.13
5.2.170.0080.23510.56
5.2.160.0080.21310.56
5.2.150.0040.22510.56
5.2.140.0070.21910.55
5.2.130.0090.21510.52
5.2.120.0070.21810.52
5.2.110.0050.21810.52
5.2.100.0050.21710.51
5.2.90.0050.22610.52
5.2.80.0060.22610.51
5.2.70.0040.22610.51
5.2.60.0060.26410.46
5.2.50.0080.23110.44
5.2.40.0060.23810.41
5.2.30.0030.22110.29
5.2.20.0090.22310.29
5.2.10.0050.22810.19
5.2.00.0070.21210.05
5.1.60.0070.2039.85
5.1.50.0040.2119.85
5.1.40.0040.2289.83
5.1.30.0040.21010.18
5.1.20.0040.21710.20
5.1.10.0070.2099.93
5.1.00.0060.2129.93
5.0.50.0060.4578.41
5.0.40.0050.4388.27
5.0.30.0080.4618.19
5.0.20.0040.4618.05
5.0.10.0090.5008.02
5.0.00.0030.4658.02
4.4.90.0050.0134.78
4.4.80.0040.0144.75
4.4.70.0030.0154.76
4.4.60.0040.0144.76
4.4.50.0040.0144.77
4.4.40.0030.0254.71
4.4.30.0030.0154.76
4.4.20.0020.0164.84
4.4.10.0020.0164.85
4.4.00.0020.0264.76
4.3.110.0040.0154.67
4.3.100.0020.0154.66
4.3.90.0020.0154.63
4.3.80.0010.0264.60
4.3.70.0020.0154.63
4.3.60.0020.0154.62
4.3.50.0030.0184.63
4.3.40.0030.0244.55
4.3.30.0030.0153.36
4.3.20.0040.0203.34
4.3.10.0010.0203.30
4.3.00.0130.0307.20

preferences:
39.13 ms | 401 KiB | 5 Q