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*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.04015.48
7.3.120.0140.04115.49
7.3.110.0070.04514.86
7.3.100.0030.04015.24
7.3.90.0000.04215.07
7.3.80.0060.03815.26
7.3.70.0040.03914.89
7.3.60.0070.03315.03
7.3.50.0040.03615.02
7.3.40.0000.03815.23
7.3.30.0000.04315.21
7.3.20.0070.03516.47
7.3.10.0150.03616.43
7.3.00.0180.03216.47
7.2.250.0040.04915.63
7.2.240.0100.03115.20
7.2.230.0030.03515.43
7.2.220.0000.03915.42
7.2.210.0000.04215.32
7.2.200.0100.03315.41
7.2.190.0030.03515.43
7.2.180.0070.03415.27
7.2.170.0070.03515.41
7.2.130.0180.03316.64
7.2.120.0220.03916.42
7.2.110.0160.04216.52
7.2.100.0230.03216.52
7.2.90.0100.03616.36
7.2.80.0100.04116.25
7.2.70.0190.03416.65
7.2.60.0150.04416.18
7.2.50.0130.03616.58
7.2.40.0090.04116.30
7.2.30.0190.04016.53
7.2.20.0160.03716.44
7.2.10.0200.04116.57
7.2.00.0160.03418.22
7.1.330.0070.05315.68
7.1.320.0030.05715.62
7.1.310.0030.05615.88
7.1.300.0130.04815.77
7.1.290.0070.04915.86
7.1.280.0030.05415.70
7.1.270.0030.05115.98
7.1.260.0030.05715.83
7.1.250.0000.07015.36
7.1.70.0060.02817.09
7.1.60.0030.05119.40
7.1.50.0000.03417.04
7.1.00.0000.11722.48
7.0.200.0140.02816.75
7.0.140.0130.10022.00
7.0.60.0100.06021.71
7.0.50.0100.10718.19
7.0.40.0100.09720.22
7.0.30.0300.10020.24
7.0.20.0270.11320.25
7.0.10.0030.07020.15
7.0.00.0030.07020.08
5.6.280.0000.26722.12
5.6.210.0070.23321.81
5.6.200.0130.23319.42
5.6.190.0100.23021.74
5.6.180.0470.19321.65
5.6.170.0230.22321.58
5.6.160.0200.21721.74
5.6.150.0200.22319.41
5.6.140.0030.19019.44
5.6.130.0030.18019.43
5.6.120.0600.15022.34
5.6.110.0070.23022.43
5.6.100.0100.21722.34
5.6.90.0170.21722.27
5.6.80.0130.26021.69
5.5.350.0230.22721.79
5.5.340.0130.19319.26
5.5.330.0100.23021.50
5.5.320.0200.21721.55
5.5.310.0370.21321.41
5.5.300.0100.20319.26
5.5.290.0100.20019.26
5.5.280.0070.23322.19
5.5.270.0000.19722.09
5.5.260.0070.22021.98
5.5.250.0000.25322.08
5.5.240.0030.21321.66
5.4.450.0270.18720.78
5.4.440.0330.17020.53
5.4.430.0300.16720.67
5.4.420.0230.19020.71
5.4.410.0330.21020.47
5.4.400.0370.17720.45
5.4.390.0200.17720.35
5.4.380.0270.17320.20
5.4.370.0370.23320.35
5.4.360.0330.17020.19
5.4.350.0330.19020.40
5.4.340.0330.24020.25
5.4.320.0300.17320.27
5.4.310.0330.16020.45
5.4.300.0230.17320.19
5.4.290.0230.17320.25
5.4.280.0430.19720.19
5.4.270.0270.16720.35
5.4.260.0230.17320.30
5.4.250.0270.18020.26
5.4.240.0230.17320.34
5.4.230.0300.23320.44
5.4.220.0300.17320.31
5.4.210.0270.16320.20
5.4.200.0270.20320.40
5.4.190.0300.16720.18
5.4.180.0300.17320.28
5.4.170.0300.17720.34
5.4.160.0330.16720.11
5.4.150.0330.22720.29
5.4.140.0300.17317.54
5.4.130.0670.16717.54
5.4.120.0300.17717.65
5.4.110.0300.16317.74
5.4.100.0270.23717.79
5.4.90.0330.16017.67
5.4.80.0270.16317.62
5.4.70.0270.18317.73
5.4.60.0370.18317.82
5.4.50.0330.23717.73
5.4.40.0200.17317.72
5.4.30.0400.22017.75
5.4.20.0230.17017.78
5.4.10.0270.16717.60
5.4.00.0330.16317.15
5.3.290.0300.20015.98
5.3.280.0300.19715.95
5.3.270.0330.22315.94
5.3.260.0270.21015.88
5.3.250.0330.21016.04
5.3.240.0400.16715.92
5.3.230.0270.17715.98
5.3.220.0300.19315.78
5.3.210.0300.17015.83
5.3.200.0370.23315.86
5.3.190.0270.17715.93
5.3.180.0270.17715.87
5.3.170.0300.17015.85
5.3.160.0300.19015.92
5.3.150.0300.17715.91
5.3.140.0270.18015.86
5.3.130.0270.17315.80
5.3.120.0330.16715.86
5.3.110.0270.17715.90
5.3.100.0270.17315.23
5.3.90.0300.22015.32
5.3.80.0270.18015.27
5.3.70.0270.17315.30
5.3.60.0270.19715.27
5.3.50.0270.17715.22
5.3.40.0300.20015.18
5.3.30.0270.19315.13
5.3.20.0370.17714.93
5.3.10.0330.16715.02
5.3.00.0370.19314.84
5.2.170.0200.19012.12
5.2.160.0270.24312.20
5.2.150.0230.18712.24
5.2.140.0200.21012.26
5.2.130.0200.18712.14
5.2.120.0230.19312.18
5.2.110.0230.18712.31
5.2.100.0170.20012.22
5.2.90.0330.17712.16
5.2.80.0270.21712.21
5.2.70.0230.18312.15
5.2.60.0530.19012.09
5.2.50.0300.18312.07
5.2.40.0200.18712.07
5.2.30.0330.29312.08
5.2.20.0130.19012.14
5.2.10.0170.19712.03
5.2.00.0200.25711.73
5.1.60.0170.18311.72
5.1.50.0270.17711.72
5.1.40.0200.18311.69
5.1.30.0130.18712.03
5.1.20.0170.21712.24
5.1.10.0130.21711.84
5.1.00.0170.18311.93
5.0.50.0070.36010.28
5.0.40.0100.40710.29
5.0.30.0100.4809.93
5.0.20.0100.3639.93
5.0.10.0070.4279.88
5.0.00.0100.3679.94
4.4.90.0070.0207.87
4.4.80.0130.0107.87
4.4.70.0130.0207.87
4.4.60.0130.0177.87
4.4.50.0130.0107.87
4.4.40.0100.0307.87
4.4.30.0100.0177.87
4.4.20.0070.0177.87
4.4.10.0100.0137.87
4.4.00.0070.0277.87
4.3.110.0170.0137.87
4.3.100.0070.0237.87
4.3.90.0100.0237.87
4.3.80.0100.0237.87
4.3.70.0100.0137.87
4.3.60.0100.0177.87
4.3.50.0070.0177.87
4.3.40.0100.0237.87
4.3.30.0030.0177.87
4.3.20.0030.0177.87
4.3.10.0030.0177.87
4.3.00.0070.0137.87

preferences:
30.61 ms | 401 KiB | 5 Q