3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convertOld($input) { $oldMin = 0; $oldMax = 1; $newMin = 127; $newMax = 0; return ceil(((($input- $oldMin) * ($newMax - $newMin)) / ($oldMax - $oldMin)) + $newMin); } function convertNew($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; } $start = microtime(1); foreach (range(0,1,1/1000) as $input) { convertOld($input); } echo "Old time: ".(microtime(1) - $start)."\n"; $start = microtime(1); foreach (rang(0,1,1/1000) as $input) { convertNew($input); } echo "New time: ".(microtime(1) - $start)."\n"; $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.0070.00915.64
7.4.00.0090.01016.04
7.3.130.0070.01015.77
7.3.120.0090.00815.45
7.3.110.0100.00615.36
7.3.100.0060.00915.55
7.3.90.0080.00815.27
7.3.80.0080.00715.31
7.3.70.0040.01015.39
7.3.60.0080.00915.44
7.3.50.0060.00915.29
7.3.40.0090.00415.39
7.3.30.0060.01015.49
7.3.20.0090.00717.15
7.3.10.0070.01017.06
7.3.00.0090.00417.12
7.2.260.0090.01115.93
7.2.250.0090.00815.91
7.2.240.0090.00515.65
7.2.230.0040.01215.56
7.2.220.0080.00715.62
7.2.210.0070.00815.57
7.2.200.0120.00415.66
7.2.190.0040.01115.52
7.2.180.0090.00615.69
7.2.170.0070.00815.62
7.2.160.0080.00915.61
7.2.150.0080.00817.40
7.2.140.0060.01017.29
7.2.130.0060.01117.27
7.2.120.0100.00517.43
7.2.110.0060.00717.30
7.2.100.0070.01017.28
7.2.90.0050.01117.47
7.2.80.0020.01217.43
7.2.70.0090.00717.32
7.2.60.0140.00217.36
7.2.50.0060.01017.19
7.2.40.0080.00517.49
7.2.30.0090.00817.49
7.2.20.0050.01117.23
7.2.10.0090.00817.29
7.2.00.0090.00617.96
7.1.330.0060.00716.27
7.1.320.0060.00516.42
7.1.310.0100.00416.30
7.1.300.0100.00716.26
7.1.290.0050.00916.18
7.1.280.0070.00816.21
7.1.270.0070.01016.21
7.1.260.0090.00616.30
7.1.250.0070.00616.21
7.1.240.0020.01216.44
7.1.230.0020.01216.34
7.1.220.0100.00816.40
7.1.210.0080.00616.51
7.1.200.0040.00916.37
7.1.190.0080.00616.51
7.1.180.0070.00516.36
7.1.170.0070.00916.41
7.1.160.0060.00816.34
7.1.150.0050.01116.50
7.1.140.0040.01216.41
7.1.130.0090.00516.47
7.1.120.0050.00816.38
7.1.110.0020.01416.33
7.1.100.0070.00816.60
7.1.90.0070.00716.45
7.1.80.0030.00916.51
7.1.70.0070.00716.60
7.1.60.0040.00917.33
7.1.50.0080.00816.63
7.1.40.0060.01116.44
7.1.30.0080.00816.66
7.1.20.0050.01116.44
7.1.10.0030.00816.49
7.1.00.0060.03018.43
7.0.330.0050.01016.25
7.0.320.0060.00816.19
7.0.310.0070.00716.34
7.0.300.0050.01016.29
7.0.290.0070.00716.09
7.0.280.0040.00816.12
7.0.270.0070.00415.99
7.0.260.0050.00716.16
7.0.250.0070.00716.45
7.0.240.0050.00816.33
7.0.230.0000.01216.23
7.0.220.0050.00716.24
7.0.210.0130.00216.18
7.0.200.0090.00316.29
7.0.190.0050.00716.30
7.0.180.0050.01016.38
7.0.170.0100.00516.28
7.0.160.0080.00616.26
7.0.150.0050.00816.32
7.0.140.0070.02818.20
7.0.130.0080.00716.23
7.0.120.0040.00916.33
7.0.110.0030.01016.28
7.0.100.0050.00716.27
7.0.90.0050.00816.26
7.0.80.0050.01016.30
7.0.70.0080.00616.21
7.0.60.0070.03117.58
7.0.50.0040.03316.86
7.0.40.0080.03116.14
7.0.30.0110.02716.18
7.0.20.0160.02416.06
7.0.10.0050.01816.05
7.0.00.0030.03816.03
5.6.400.0030.01215.23
5.6.390.0050.00915.22
5.6.380.0000.01415.36
5.6.370.0050.01215.06
5.6.360.0070.00915.34
5.6.350.0050.01115.24
5.6.340.0080.00515.15
5.6.330.0030.01115.11
5.6.320.0040.01215.06
5.6.310.0060.00915.31
5.6.300.0030.01015.16
5.6.290.0070.00715.09
5.6.280.0050.03217.02
5.6.270.0070.01015.15
5.6.260.0070.00715.07
5.6.250.0030.01115.15
5.6.240.0080.00615.04
5.6.230.0050.01015.14
5.6.220.0110.00515.07
5.6.210.0060.02916.93
5.6.200.0040.02616.12
5.6.190.0080.03017.03
5.6.180.0140.03416.77
5.6.170.0150.02916.85
5.6.160.0040.03516.92
5.6.150.0070.03316.14
5.6.140.0070.02516.15
5.6.130.0050.03816.21
5.6.120.0120.03017.19
5.6.110.0090.03116.97
5.6.100.0050.03116.95
5.6.90.0080.01816.91
5.6.80.0050.03516.82
5.6.70.0060.00814.89
5.6.60.0040.00914.90
5.6.50.0090.00515.15
5.6.40.0050.01015.20
5.6.30.0050.00614.95
5.6.20.0050.00914.98
5.6.10.0080.01014.90
5.6.00.0000.01515.14
5.5.380.0060.00814.91
5.5.370.0080.01015.18
5.5.360.0040.00914.91
5.5.350.0170.02816.86
5.5.340.0070.03315.99
5.5.330.0080.02616.79
5.5.320.0150.02317.02
5.5.310.0120.02516.85
5.5.300.0020.02815.91
5.5.290.0030.03016.00
5.5.280.0020.02217.02
5.5.270.0030.03917.08
5.5.260.0070.03116.87
5.5.250.0020.02116.84
5.5.240.0050.03216.64
5.5.230.0090.00414.82
5.5.220.0070.00715.05
5.5.210.0110.00314.95
5.5.200.0050.01015.03
5.5.190.0020.01514.94
5.5.180.0090.00714.94
5.5.170.0090.00514.73
5.5.160.0040.01315.06
5.5.150.0060.01215.01
5.5.140.0120.00215.05
5.5.130.0050.01215.05
5.5.120.0110.00815.05
5.5.110.0060.01115.00
5.5.100.0050.01314.91
5.5.90.0110.00515.04
5.5.80.0050.01014.90
5.5.70.0030.01015.01
5.5.60.0080.00814.77
5.5.50.0100.00714.83
5.5.40.0060.01214.92
5.5.30.0110.00814.88
5.5.20.0080.00814.95
5.5.10.0080.00814.70
5.5.00.0060.01114.81
5.4.450.0140.03014.46
5.4.440.0290.02414.45
5.4.430.0080.02014.37
5.4.420.0080.02414.35
5.4.410.0100.02514.23
5.4.400.0060.02514.21
5.4.390.0050.02414.05
5.4.380.0070.02414.13
5.4.370.0020.02414.13
5.4.360.0050.02214.20
5.4.350.0030.01811.87
5.4.340.0060.01511.95
5.4.330.0040.00811.67
5.4.320.0060.02012.12
5.4.310.0050.01612.09
5.4.300.0080.01712.16
5.4.290.0050.01812.12
5.4.280.0060.01512.09
5.4.270.0050.01811.96
5.4.260.0090.01412.02
5.4.250.0050.01512.09
5.4.240.0050.01712.08
5.4.230.0060.01812.03
5.4.220.0030.01912.10
5.4.210.0050.01811.95
5.4.200.0070.01812.17
5.4.190.0080.01912.08
5.4.180.0090.01712.13
5.4.170.0050.01912.01
5.4.160.0070.01812.13
5.4.150.0090.01612.15
5.4.140.0060.01712.01
5.4.130.0100.01511.94
5.4.120.0070.01612.07
5.4.110.0070.01711.99
5.4.100.0050.01912.04
5.4.90.0080.01711.80
5.4.80.0060.01912.07
5.4.70.0080.01711.92
5.4.60.0070.01712.00
5.4.50.0100.01511.95
5.4.40.0100.01312.01
5.4.30.0070.01612.01
5.4.20.0070.01611.98
5.4.10.0070.01611.90
5.4.00.0050.02011.80
5.3.290.0050.04012.89
5.3.280.0030.04012.82
5.3.270.0060.03912.84
5.3.260.0050.03912.84
5.3.250.0040.03912.83
5.3.240.0050.03912.84
5.3.230.0050.03812.83
5.3.220.0080.04112.80
5.3.210.0080.04112.79
5.3.200.0060.03712.79
5.3.190.0070.03912.80
5.3.180.0060.04412.79
5.3.170.0050.04112.80
5.3.160.0060.03712.79
5.3.150.0060.03812.79
5.3.140.0090.03712.79
5.3.130.0040.04112.77
5.3.120.0040.04412.78
5.3.110.0070.05312.78
5.3.100.0030.04012.27
5.3.90.0070.03512.25
5.3.80.0060.04212.24
5.3.70.0040.04812.25
5.3.60.0040.03812.22
5.3.50.0050.05312.17
5.3.40.0050.04412.17
5.3.30.0080.03312.13
5.3.20.0070.04311.91
5.3.10.0020.04111.88
5.3.00.0040.04411.86
5.2.170.0030.0389.36
5.2.160.0020.0339.36
5.2.150.0050.0359.36
5.2.140.0030.0399.36
5.2.130.0050.0309.32
5.2.120.0050.0319.32
5.2.110.0050.0309.32
5.2.100.0050.0329.32
5.2.90.0060.0319.32
5.2.80.0060.0309.32
5.2.70.0050.0319.31
5.2.60.0050.0389.27
5.2.50.0050.0399.24
5.2.40.0030.0319.22
5.2.30.0060.0399.19
5.2.20.0060.0349.18
5.2.10.0090.0339.10
5.2.00.0060.0358.96
5.1.60.0060.0338.29
5.1.50.0030.0328.28
5.1.40.0050.0368.26
5.1.30.0060.0318.61
5.1.20.0070.0348.64
5.1.10.0010.0308.36
5.1.00.0040.0278.36
5.0.50.0020.0246.84
5.0.40.0050.0276.70
5.0.30.0030.0346.52
5.0.20.0030.0216.48
5.0.10.0020.0236.46
5.0.00.0030.0336.46
4.4.90.0010.0174.78
4.4.80.0020.0164.75
4.4.70.0020.0154.75
4.4.60.0040.0254.76
4.4.50.0050.0164.77
4.4.40.0030.0244.71
4.4.30.0030.0234.76
4.4.20.0010.0174.84
4.4.10.0010.0174.85
4.4.00.0050.0234.76
4.3.110.0050.0184.67
4.3.100.0020.0154.66
4.3.90.0040.0214.63
4.3.80.0030.0304.60
4.3.70.0030.0324.63
4.3.60.0030.0164.63
4.3.50.0040.0214.63
4.3.40.0060.0274.55
4.3.30.0040.0213.36
4.3.20.0030.0143.34
4.3.10.0010.0233.30
4.3.00.0030.0236.85

preferences:
38.25 ms | 400 KiB | 5 Q