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 (($diffNew-$diffOld)/$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.2.00.0070.03019.55
7.1.70.0030.03916.93
7.1.60.0160.04619.40
7.1.50.0070.04217.02
7.1.00.0030.11322.57
7.0.200.0030.02616.78
7.0.140.0030.10722.08
7.0.60.0030.06020.30
7.0.50.0030.08718.24
7.0.40.0070.06720.15
7.0.30.0370.10020.13
7.0.20.0270.07720.21
7.0.10.0000.12320.23
7.0.00.0100.08020.06
5.6.280.0070.24722.45
5.6.210.0070.23021.81
5.6.200.0030.19719.46
5.6.190.0070.23021.65
5.6.180.0300.19321.79
5.6.170.0230.18021.70
5.6.160.0030.23021.62
5.6.150.0130.22319.44
5.6.140.0070.19719.53
5.6.130.0070.19319.43
5.6.120.0100.17722.34
5.6.110.0070.22722.21
5.6.100.0030.21322.31
5.6.90.0030.20322.42
5.6.80.0170.16021.77
5.6.70.0100.22321.78
5.5.350.0300.23721.79
5.5.340.0170.21719.22
5.5.330.0070.18021.47
5.5.320.0430.20321.27
5.5.310.0270.22721.53
5.5.300.0100.20719.24
5.5.290.0100.23019.24
5.5.280.0030.17722.23
5.5.270.0100.19022.10
5.5.260.0130.21722.14
5.5.250.0130.22721.83
5.5.240.0200.23021.56
5.4.450.0970.30020.61
5.4.440.0470.25720.56
5.4.430.0700.24020.82
5.4.420.0670.24720.69
5.4.410.0100.25020.03
5.4.400.0470.28720.06
5.4.390.0570.29019.95
5.4.380.0200.24720.06
5.4.370.0200.19019.82
5.4.360.0000.21020.04
5.4.350.0110.21213.32
5.4.340.0130.18713.31
5.4.320.0090.18913.80
5.4.310.0080.18413.80
5.4.300.0090.18613.80
5.4.290.0080.18413.79
5.4.280.0080.19513.69
5.4.270.0070.18613.70
5.4.260.0080.19013.69
5.4.250.0070.20213.69
5.4.240.0090.21413.69
5.4.230.0080.19413.68
5.4.220.0060.18913.69
5.4.210.0050.18413.68
5.4.200.0080.18313.68
5.4.190.0070.19113.68
5.4.180.0060.19413.68
5.4.170.0060.19313.69
5.4.160.0070.19213.69
5.4.150.0060.18913.68
5.4.140.0070.19813.36
5.4.130.0090.18813.35
5.4.120.0070.18913.31
5.4.110.0070.19113.31
5.4.100.0080.20113.31
5.4.90.0090.18913.30
5.4.80.0090.18613.30
5.4.70.0070.19013.30
5.4.60.0080.18613.30
5.4.50.0100.18413.30
5.4.40.0040.19013.29
5.4.30.0090.19113.28
5.4.20.0090.19013.29
5.4.10.0080.19313.29
5.4.00.0050.18812.77
5.3.290.0050.20014.16
5.3.280.0060.19614.09
5.3.270.0070.19614.10
5.3.260.0040.20414.11
5.3.250.0040.19414.10
5.3.240.0110.18814.10
5.3.230.0080.19314.10
5.3.220.0070.19214.07
5.3.210.0050.18914.07
5.3.200.0090.19214.06
5.3.190.0070.20014.07
5.3.180.0090.21114.06
5.3.170.0080.19914.07
5.3.160.0080.20814.06
5.3.150.0080.19514.07
5.3.140.0080.19114.05
5.3.130.0070.19214.05
5.3.120.0060.19814.05
5.3.110.0060.19414.04
5.3.100.0070.19913.54
5.3.90.0110.18813.52
5.3.80.0060.19213.57
5.3.70.0080.18813.50
5.3.60.0050.20013.49
5.3.50.0060.19213.44
5.3.40.0080.19113.44
5.3.30.0070.20113.40
5.3.20.0090.20513.18
5.3.10.0050.19513.15
5.3.00.0050.20913.13
5.2.170.0090.21210.61
5.2.160.0110.23710.55
5.2.150.0080.21610.56
5.2.140.0070.21810.55
5.2.130.0090.20710.52
5.2.120.0060.21510.52
5.2.110.0070.21810.52
5.2.100.0050.21310.52
5.2.90.0050.21610.52
5.2.80.0070.21910.51
5.2.70.0030.21710.51
5.2.60.0070.21110.46
5.2.50.0100.21410.43
5.2.40.0120.20810.41
5.2.30.0080.21310.29
5.2.20.0070.21210.29
5.2.10.0080.22510.19
5.2.00.0050.21810.05
5.1.60.0070.2099.86
5.1.50.0160.2009.85
5.1.40.0050.2119.83
5.1.30.0050.22810.18
5.1.20.0080.20710.20
5.1.10.0040.2119.93
5.1.00.0040.2149.93
5.0.50.0050.4748.41
5.0.40.0050.4388.27
5.0.30.0090.4648.08
5.0.20.0080.4568.05
5.0.10.0070.4438.03
5.0.00.0120.4548.02
4.4.90.0030.0154.77
4.4.80.0030.0154.76
4.4.70.0020.0164.76
4.4.60.0030.0154.75
4.4.50.0020.0164.77
4.4.40.0000.0284.71
4.4.30.0040.0144.75
4.4.20.0020.0164.85
4.4.10.0030.0154.85
4.4.00.0010.0264.76
4.3.110.0050.0134.67
4.3.100.0030.0144.67
4.3.90.0020.0154.64
4.3.80.0030.0244.60
4.3.70.0020.0144.63
4.3.60.0050.0124.63
4.3.50.0020.0164.63
4.3.40.0010.0264.56
4.3.30.0010.0173.36
4.3.20.0040.0143.34
4.3.10.0020.0153.30
4.3.00.0130.0207.20

preferences:
39.02 ms | 400 KiB | 5 Q