3v4l.org

run code in 300+ PHP versions simultaneously
<?php class IDN { // adapt bias for punycode algorithm private static function punyAdapt( $delta, $numpoints, $firsttime ) { $delta = $firsttime ? $delta / 700 : $delta / 2; $delta += $delta / $numpoints; for ($k = 0; $delta > 455; $k += 36) $delta = intval($delta / 35); return $k + (36 * $delta) / ($delta + 38); } // make utf8 string from unicode codepoint number private static function utf8($cp) { if ($cp < 128) return chr($cp); if ($cp < 2048) return chr(192+($cp >> 6)).chr(128+($cp & 63)); if ($cp < 65536) return chr(224+($cp >> 12)). chr(128+(($cp >> 6) & 63)). chr(128+($cp & 63)); if ($cp < 2097152) return chr(240+($cp >> 18)). chr(128+(($cp >> 12) & 63)). chr(128+(($cp >> 6) & 63)). chr(128+($cp & 63)); // it should never get here } // main decoding function private static function decodePart($input) { if (substr($input, 0, 4) !== 'xn--') { return $input; } $input = substr($input, 4); if (false !== $nonBasicCharsStart = strrpos($input, '-')) { $output = str_split(substr($input, 0, $nonBasicCharsStart), 1); $input = str_split(substr($input, $nonBasicCharsStart + 1), 1); } else { $input = str_split($input, 1); $output = []; } $n = 128; $i = 0; $bias = 72; // init punycode vars while (!empty($input)) { $oldi = $i; $w = 1; for ($k = 36;;) { $digit = ord(array_shift($input)); if ($digit >= 0x61 && $digit <= 0x7A) { $digit -= 97; } else if ($digit >= 0x30 && $digit <= 0x39) { $digit -= 22; } else { return false; } $i += $digit * $w; if ($k <= $bias) { $t = 1; } else if ($k >= $bias + 26) { $t = 26; } else { $t = $k - $bias; } if ($digit < $t) { break; } $w *= (int) (36 - $t); $k += 36; } $bias = IDN::punyAdapt( $i-$oldi, count($output)+1, $oldi == 0 ); $n += intval($i / (count($output) + 1)); $i %= count($output) + 1; array_splice($output,$i,0,array(IDN::utf8($n))); $i++; } return implode("",$output); } public static function decodeIDN($name) { // split it, parse it and put it back together return implode( ".", array_map("IDN::decodePart",explode(".",$name)) ); } } echo IDN::decodeIDN("xn---with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n");

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)
8.3.60.0030.01716.63
8.3.50.0120.00617.36
8.3.40.0150.00418.79
8.3.30.0120.00318.91
8.3.20.0000.00818.83
8.3.10.0080.00020.56
8.3.00.0060.00319.25
8.2.180.0070.01116.75
8.2.170.0120.00322.96
8.2.160.0070.00721.20
8.2.150.0030.00524.18
8.2.140.0040.00424.66
8.2.130.0000.00826.16
8.2.120.0080.00020.89
8.2.110.0030.00620.43
8.2.100.0070.00418.16
8.2.90.0000.00819.17
8.2.80.0000.00817.97
8.2.70.0030.00517.50
8.2.60.0040.00417.92
8.2.50.0040.00418.07
8.2.40.0080.00018.16
8.2.30.0040.00418.07
8.2.20.0040.00417.72
8.2.10.0030.00517.88
8.2.00.0060.00317.79
8.1.280.0050.01025.92
8.1.270.0140.00424.66
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0000.00923.63
8.1.230.0060.00619.09
8.1.220.0080.00017.91
8.1.210.0040.00418.77
8.1.200.0090.00017.25
8.1.190.0000.00817.23
8.1.180.0060.00318.10
8.1.170.0040.00418.71
8.1.160.0070.00022.11
8.1.150.0000.01018.67
8.1.140.0000.00817.49
8.1.130.0000.00717.88
8.1.120.0080.00017.44
8.1.110.0000.00717.53
8.1.100.0000.00717.50
8.1.90.0000.00717.41
8.1.80.0040.00417.44
8.1.70.0040.00417.33
8.1.60.0040.00417.64
8.1.50.0000.00817.50
8.1.40.0040.00417.58
8.1.30.0020.00517.59
8.1.20.0040.00417.71
8.1.10.0040.00417.63
8.1.00.0000.01017.54
8.0.300.0050.00318.77
8.0.290.0040.00417.00
8.0.280.0000.00718.43
8.0.270.0070.00017.21
8.0.260.0070.00016.84
8.0.250.0030.00616.97
8.0.240.0080.00317.11
8.0.230.0000.00717.00
8.0.220.0040.00417.00
8.0.210.0070.00016.89
8.0.200.0030.00317.04
8.0.190.0000.00817.04
8.0.180.0040.00417.04
8.0.170.0000.00916.99
8.0.160.0050.00317.08
8.0.150.0040.00416.94
8.0.140.0040.00417.03
8.0.130.0030.00313.37
8.0.120.0000.00716.94
8.0.110.0040.00417.01
8.0.100.0070.00016.83
8.0.90.0080.00017.07
8.0.80.0000.01516.88
8.0.70.0000.00716.80
8.0.60.0000.00817.06
8.0.50.0000.00716.88
8.0.30.0110.01117.16
8.0.20.0100.01017.14
8.0.10.0000.00717.14
8.0.00.0080.01216.73
7.4.330.0020.00212.98
7.4.320.0030.00316.64
7.4.300.0030.00316.50
7.4.290.0040.00416.57
7.4.280.0040.00416.48
7.4.270.0000.00916.47
7.4.260.0000.00713.32
7.4.250.0040.00416.64
7.4.240.0040.00316.57
7.4.230.0000.00716.55
7.4.220.0060.01016.59
7.4.210.0050.01116.61
7.4.200.0040.00416.76
7.4.190.0030.00316.69
7.4.160.0030.01416.57
7.4.150.0140.01016.44
7.4.140.0050.01316.49
7.4.130.0070.01016.58
7.4.120.0070.01116.51
7.4.110.0070.01116.68
7.4.100.0090.00916.65
7.4.90.0110.00716.40
7.4.80.0030.01319.39
7.4.70.0090.00916.61
7.4.60.0110.00616.51
7.4.50.0060.00616.67
7.4.40.0070.01116.69
7.4.30.0070.01716.62
7.4.00.0100.00614.90
7.3.330.0030.00313.48
7.3.320.0030.00313.34
7.3.310.0000.00716.50
7.3.300.0070.00016.43
7.3.290.0110.00316.47
7.3.280.0060.01116.51
7.3.270.0140.00516.47
7.3.260.0090.01216.60
7.3.250.0090.01016.50
7.3.240.0120.00616.45
7.3.230.0070.01116.68
7.3.210.0100.01016.47
7.3.200.0100.01016.46
7.3.190.0080.01216.46
7.3.180.0120.00616.44
7.3.170.0040.01216.50
7.3.160.0100.00816.46
7.3.120.0070.01114.88
7.3.110.0140.00714.96
7.3.100.0090.00614.92
7.3.90.0040.01115.03
7.3.80.0060.00915.09
7.3.70.0030.01415.07
7.3.60.0070.00714.88
7.3.50.0070.00715.01
7.3.40.0030.01214.86
7.3.30.0090.00314.97
7.3.20.0060.00916.88
7.3.10.0110.00316.88
7.3.00.0050.00516.67
7.2.330.0060.01316.57
7.2.320.0060.01516.55
7.2.310.0060.01216.88
7.2.300.0080.00816.80
7.2.290.0110.01216.62
7.2.250.0040.01515.04
7.2.240.0110.01115.32
7.2.230.0150.00015.14
7.2.220.0100.01015.24
7.2.210.0090.00615.07
7.2.200.0030.00715.27
7.2.190.0070.00715.10
7.2.180.0070.00415.15
7.2.170.0060.01215.17
7.1.330.0060.01015.57
7.1.320.0090.00615.75
7.1.310.0060.00915.87
7.1.300.0090.00615.78
7.1.290.0100.00715.62
7.1.280.0070.00715.83
7.1.270.0040.00715.76
7.1.260.0050.00515.61
7.1.100.0220.01116.38
7.1.70.0050.00317.06
7.1.60.0150.00919.40
7.1.50.0100.00316.84
7.1.00.0030.04022.32
7.0.200.0050.00316.86
7.0.140.0000.07322.20
7.0.120.0030.07322.16
7.0.60.0070.05019.97
7.0.50.0000.05017.92
7.0.40.0100.03720.04
7.0.30.0330.07320.26
7.0.20.0330.03720.30
7.0.10.0170.05320.22
7.0.00.0030.09720.08
5.6.280.0030.07321.13
5.6.210.0070.05720.64
5.6.200.0100.07318.19
5.6.190.0100.05320.46
5.6.180.0230.04720.35
5.6.170.0170.05020.45
5.6.160.0100.07020.57
5.6.150.0230.06318.27
5.6.140.0130.07018.13
5.6.130.0070.03718.29
5.6.120.0070.06721.04
5.6.110.0130.08321.04
5.6.100.0100.07721.16
5.6.90.0100.08721.00
5.6.80.0100.04020.55
5.6.70.0070.04720.38
5.5.350.0330.06720.46
5.5.340.0130.07718.09
5.5.330.0070.08320.41
5.5.320.0200.06720.58
5.5.310.0230.04720.30
5.5.300.0000.07017.96
5.5.290.0130.06717.98
5.5.280.0070.04020.70
5.5.270.0170.07720.82
5.5.260.0030.08720.78
5.5.250.0100.03320.52
5.5.240.0170.06320.29
5.4.450.0130.04319.33
5.4.440.0100.06719.53
5.4.430.0030.05319.56
5.4.420.0070.07719.56
5.4.410.0030.05019.05
5.4.400.0030.05319.15
5.4.390.0070.07719.15
5.4.380.0170.06718.92
5.4.370.0130.06719.24
5.4.360.0000.05319.15
5.4.350.0000.05019.12
5.4.340.0030.05719.08
5.4.320.0130.07319.00
5.4.310.0130.03719.12
5.4.300.0030.07719.16
5.4.290.0100.04719.15
5.4.280.0130.07019.20
5.4.270.0130.05318.96
5.4.260.0030.05019.14
5.4.250.0070.08019.14
5.4.240.0030.08018.86
5.4.230.0070.06319.07
5.4.220.0100.07318.96
5.4.210.0030.06019.23
5.4.200.0030.04019.14
5.4.190.0000.08018.86
5.4.180.0100.06319.19
5.4.170.0100.05018.84
5.4.160.0030.07718.98
5.4.150.0100.07018.98
5.4.140.0100.04316.33
5.4.130.0130.06716.35
5.4.120.0030.04316.29
5.4.110.0100.05016.39
5.4.100.0100.06316.55
5.4.90.0100.05016.42
5.4.80.0130.06316.43
5.4.70.0100.07016.40
5.4.60.0070.04716.42
5.4.50.0000.06716.38
5.4.40.0070.06716.50
5.4.30.0130.05316.39
5.4.20.0070.07316.41
5.4.10.0070.03716.47
5.4.00.0030.04715.83
5.3.290.0030.05014.70
5.3.280.0030.06314.54
5.3.270.0030.08014.63
5.3.260.0070.03714.58
5.3.250.0130.04014.64
5.3.240.0030.05314.55
5.3.230.0030.06014.76
5.3.220.0070.06714.66
5.3.210.0070.08314.59
5.3.200.0070.07014.60
5.3.190.0070.08014.63
5.3.180.0100.04314.62
5.3.170.0070.04314.62
5.3.160.0030.05714.72
5.3.150.0030.06314.58
5.3.140.0030.07314.50
5.3.130.0000.04314.71
5.3.120.0070.05014.60
5.3.110.0130.07014.73
5.3.100.0030.04014.13
5.3.90.0030.03714.08
5.3.80.0070.08014.04
5.3.70.0070.07314.10
5.3.60.0070.04014.03
5.3.50.0030.07313.93
5.3.40.0070.07314.02
5.3.30.0030.06313.93
5.3.20.0030.08013.71
5.3.10.0170.04013.75
5.3.00.0070.05313.73
5.2.170.0070.03311.32
5.2.160.0070.03011.13
5.2.150.0070.06011.32
5.2.140.0000.04011.14
5.2.130.0070.05711.29
5.2.120.0030.07011.20
5.2.110.0030.03311.12
5.2.100.0100.06011.29
5.2.90.0070.05311.28
5.2.80.0070.05011.04
5.2.70.0130.05311.08
5.2.60.0070.04711.10
5.2.50.0070.05711.04
5.2.40.0100.06011.01
5.2.30.0030.06010.96
5.2.20.0070.05710.91
5.2.10.0030.05710.89
5.2.00.0070.05010.79
5.1.60.0100.0479.99
5.1.50.0030.03710.18
5.1.40.0100.02710.04
5.1.30.0000.05010.41
5.1.20.0000.05010.38
5.1.10.0030.04710.12
5.1.00.0000.05310.07
5.0.50.0000.0538.59
5.0.40.0030.0438.48
5.0.30.0070.0508.41
5.0.20.0000.0408.27
5.0.10.0030.0438.27
5.0.00.0030.0638.16
4.4.90.0030.0338.01
4.4.80.0000.0378.01
4.4.70.0000.0278.01
4.4.60.0000.0208.01
4.4.50.0070.0308.01
4.4.40.0030.0538.01
4.4.30.0070.0238.01
4.4.20.0000.0378.01
4.4.10.0030.0238.01
4.4.00.0000.0378.01
4.3.110.0070.0108.01
4.3.100.0030.0338.01
4.3.90.0000.0378.01
4.3.80.0000.0438.01
4.3.70.0000.0308.01
4.3.60.0000.0378.01
4.3.50.0000.0278.01
4.3.40.0000.0308.01
4.3.30.0000.0378.01
4.3.20.0000.0278.01
4.3.10.0030.0178.01
4.3.00.0000.0178.01

preferences:
46.44 ms | 401 KiB | 5 Q