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*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.10.0100.03315.17
7.4.00.0070.04615.45
7.3.130.0100.04415.35
7.3.120.0080.04115.31
7.3.110.0060.04315.10
7.3.100.0030.03715.20
7.3.90.0070.03415.04
7.3.80.0050.03415.31
7.3.70.0080.03815.37
7.3.60.0050.03415.29
7.3.50.0050.03415.17
7.3.40.0050.03514.99
7.3.30.0120.02714.93
7.3.20.0030.03716.63
7.3.10.0070.03216.75
7.3.00.0060.03416.63
7.2.260.0130.04015.37
7.2.250.0140.03515.31
7.2.240.0070.04115.40
7.2.230.0050.03915.47
7.2.220.0030.03815.44
7.2.210.0030.03715.29
7.2.200.0070.03815.36
7.2.190.0070.03115.47
7.2.180.0030.03715.41
7.2.170.0050.03715.33
7.2.160.0030.03815.42
7.2.150.0050.03616.97
7.2.140.0080.03417.09
7.2.130.0110.03016.95
7.2.120.0040.03516.93
7.2.110.0060.03317.00
7.2.100.0030.03716.85
7.2.90.0070.03616.94
7.2.80.0080.03416.95
7.2.70.0090.03516.84
7.2.60.0070.03716.93
7.2.50.0020.03916.94
7.2.40.0050.03816.94
7.2.30.0030.03816.90
7.2.20.0050.03816.98
7.2.10.0100.03617.01
7.2.00.0050.03517.50
7.1.330.0110.04716.01
7.1.320.0070.06315.87
7.1.310.0050.05915.85
7.1.300.0120.04815.69
7.1.290.0030.05415.88
7.1.280.0070.05315.79
7.1.270.0090.05215.78
7.1.260.0050.05415.86
7.1.250.0090.05115.67
7.1.240.0070.05015.95
7.1.230.0000.05615.68
7.1.220.0000.05715.98
7.1.210.0030.05715.69
7.1.200.0030.04915.96
7.1.190.0070.05015.71
7.1.180.0030.05515.87
7.1.170.0070.06615.79
7.1.160.0070.04915.93
7.1.150.0030.07115.80
7.1.140.0030.06315.97
7.1.130.0100.06115.94
7.1.120.0000.06215.82
7.1.110.0030.05515.81
7.1.100.0030.04815.39
7.1.90.0070.04215.65
7.1.80.0030.05515.73
7.1.70.0030.03816.53
7.1.60.0030.06217.48
7.1.50.0070.04016.29
7.1.40.0030.05615.63
7.1.30.0030.06815.98
7.1.20.0030.05015.77
7.1.10.0070.04915.75
7.1.00.0030.08019.12
7.0.330.0130.04715.34
7.0.320.0030.05315.27
7.0.310.0030.05515.40
7.0.300.0030.06115.48
7.0.290.0030.05915.39
7.0.280.0030.04615.46
7.0.270.0000.05515.37
7.0.260.0070.05215.44
7.0.250.0070.05015.55
7.0.240.0030.05315.48
7.0.230.0100.04715.32
7.0.220.0030.05315.38
7.0.210.0030.05015.52
7.0.200.0050.04416.05
7.0.190.0030.05415.52
7.0.180.0070.04415.52
7.0.170.0030.06115.39
7.0.160.0070.05115.45
7.0.150.0070.05115.55
7.0.140.0070.07418.79
7.0.130.0070.05215.38
7.0.120.0100.04815.34
7.0.110.0070.05015.24
7.0.100.0100.04615.18
7.0.90.0130.04515.51
7.0.80.0060.06215.52
7.0.70.0100.06415.47
7.0.60.0030.07817.81
7.0.50.0080.05316.74
7.0.40.0050.06016.71
7.0.30.0300.08016.75
7.0.20.0230.06216.73
7.0.10.0120.08016.78
7.0.00.0050.08116.76
5.6.400.0030.21715.74
5.6.390.0070.21515.75
5.6.380.0100.21715.74
5.6.370.0100.21315.38
5.6.360.0070.23715.81
5.6.350.0070.23216.11
5.6.340.0070.23615.65
5.6.330.0100.20215.99
5.6.320.0070.23615.98
5.6.310.0070.23115.97
5.6.300.0030.22615.70
5.6.290.0130.20715.48
5.6.280.0030.24419.08
5.6.270.0070.21815.79
5.6.260.0070.21516.02
5.6.250.0030.22015.91
5.6.240.0100.24015.71
5.6.230.0030.23515.62
5.6.220.0070.23815.50
5.6.210.0020.23618.81
5.6.200.0080.22617.59
5.6.190.0070.23118.71
5.6.180.0250.22418.45
5.6.170.0180.18218.73
5.6.160.0120.23018.69
5.6.150.0120.23917.59
5.6.140.0070.25117.42
5.6.130.0030.25317.48
5.6.120.0070.22019.17
5.6.110.0030.22618.88
5.6.100.0050.24518.95
5.6.90.0050.24319.14
5.6.80.0070.22318.62
5.6.70.0070.23615.59
5.6.60.0070.24315.82
5.6.50.0030.24515.50
5.6.40.0030.23015.56
5.6.30.0100.27515.44
5.6.20.0030.26515.59
5.6.10.0030.23615.59
5.6.00.0070.21515.52
5.5.380.0000.25115.41
5.5.370.0070.21915.50
5.5.360.0030.21215.53
5.5.350.0030.21418.67
5.5.340.0050.20617.50
5.5.330.0030.20818.54
5.5.320.2030.20818.46
5.5.310.0130.20418.54
5.5.300.0020.22217.46
5.5.290.0080.23917.44
5.5.280.0100.24519.07
5.5.270.0080.20818.96
5.5.260.0070.22418.96
5.5.250.0050.24918.79
5.5.240.0100.23118.57
5.5.230.0070.30915.84
5.5.220.0000.25815.62
5.5.210.0130.20515.39
5.5.200.0030.28815.88
5.5.190.0130.24515.63
5.5.180.0030.24715.78
5.5.170.0100.20515.84
5.5.160.0070.24115.50
5.5.150.0070.27415.65
5.5.140.0070.22915.70
5.5.130.0070.23615.32
5.5.120.0070.23315.55
5.5.110.0000.29515.52
5.5.100.0070.23515.56
5.5.90.0030.22115.68
5.5.80.0070.21315.22
5.5.70.0030.23715.51
5.5.60.0030.22115.71
5.5.50.0000.24215.86
5.5.40.0000.26715.54
5.5.30.0160.24115.79
5.5.20.0000.24415.54
5.5.10.0030.26515.45
5.5.00.0130.29615.64
5.4.450.0680.20616.81
5.4.440.0680.20516.80
5.4.430.0850.23416.81
5.4.420.0080.26216.92
5.4.410.0030.24116.64
5.4.400.0330.26216.38
5.4.390.0220.31116.51
5.4.380.0130.24416.53
5.4.370.0030.20516.48
5.4.360.0050.21216.51
5.4.350.0050.24413.15
5.4.340.0040.20813.15
5.4.330.0000.29612.99
5.4.320.0100.21113.40
5.4.310.0080.21313.39
5.4.300.0070.20113.40
5.4.290.0030.20413.39
5.4.280.0060.23513.34
5.4.270.0060.20713.34
5.4.260.0040.21413.34
5.4.250.0070.22813.34
5.4.240.0030.22513.34
5.4.230.0090.21213.34
5.4.220.0060.24013.34
5.4.210.0090.21113.34
5.4.200.0080.20313.34
5.4.190.0050.21513.34
5.4.180.0070.22213.34
5.4.170.0080.24813.34
5.4.160.0090.21313.34
5.4.150.0080.21813.34
5.4.140.0040.21813.18
5.4.130.0080.22613.17
5.4.120.0060.20513.15
5.4.110.0050.21813.15
5.4.100.0060.21313.15
5.4.90.0040.23913.15
5.4.80.0060.20513.15
5.4.70.0050.21313.15
5.4.60.0080.22613.15
5.4.50.0060.20113.14
5.4.40.0010.21013.14
5.4.30.0090.20213.14
5.4.20.0050.21813.14
5.4.10.0070.20513.14
5.4.00.0060.20412.88
5.3.290.0080.19414.16
5.3.280.0070.18914.09
5.3.270.0080.20014.11
5.3.260.0090.20214.11
5.3.250.0050.19114.11
5.3.240.0040.19314.10
5.3.230.0060.19914.10
5.3.220.0070.19114.07
5.3.210.0080.19414.07
5.3.200.0060.19514.06
5.3.190.0070.21214.07
5.3.180.0070.18914.06
5.3.170.0110.20214.07
5.3.160.0040.19214.06
5.3.150.0070.19214.06
5.3.140.0090.18514.06
5.3.130.0070.19514.04
5.3.120.0110.19114.04
5.3.110.0050.19114.05
5.3.100.0080.19013.54
5.3.90.0050.19213.52
5.3.80.0060.19213.50
5.3.70.0070.19113.50
5.3.60.0060.19313.49
5.3.50.0090.18213.44
5.3.40.0090.20113.44
5.3.30.0030.20213.41
5.3.20.0050.20713.18
5.3.10.0060.18613.14
5.3.00.0070.19413.13
5.2.170.0060.21810.56
5.2.160.0060.20710.56
5.2.150.0070.21310.56
5.2.140.0060.22310.55
5.2.130.0040.21310.52
5.2.120.0070.21210.52
5.2.110.0050.22110.52
5.2.100.0100.21210.52
5.2.90.0080.21510.52
5.2.80.0030.22110.51
5.2.70.0080.21310.51
5.2.60.0050.20910.46
5.2.50.0050.22110.44
5.2.40.0070.21510.32
5.2.30.0030.21910.29
5.2.20.0040.21510.29
5.2.10.0030.23310.19
5.2.00.0050.22010.05
5.1.60.0030.2089.85
5.1.50.0040.2159.85
5.1.40.0050.2239.83
5.1.30.0080.20810.18
5.1.20.0040.21610.20
5.1.10.0080.2129.93
5.1.00.0110.2069.93
5.0.50.0060.4778.41
5.0.40.0060.4398.27
5.0.30.0090.4648.08
5.0.20.0110.4318.05
5.0.10.0020.4348.02
5.0.00.0070.4468.02
4.4.90.0030.0184.78
4.4.80.0060.0114.75
4.4.70.0050.0124.75
4.4.60.0080.0094.76
4.4.50.0040.0134.77
4.4.40.0020.0264.71
4.4.30.0030.0154.76
4.4.20.0040.0134.84
4.4.10.0020.0204.84
4.4.00.0040.0244.76
4.3.110.0010.0174.66
4.3.100.0010.0164.66
4.3.90.0020.0154.64
4.3.80.0010.0264.61
4.3.70.0010.0164.63
4.3.60.0040.0134.63
4.3.50.0020.0164.63
4.3.40.0050.0214.56
4.3.30.0020.0163.37
4.3.20.0020.0173.34
4.3.10.0040.0133.30
4.3.00.0300.02315.85

preferences:
41.33 ms | 400 KiB | 5 Q