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); } // translate character to punycode number private static function decodeDigit($cp) { } // 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--") // prefix check... return $input; $input = substr($input,4); // discard prefix $a = explode("-",$input); if (count($a) > 1) { $input = str_split(array_pop($a)); $output = str_split(implode("-",$a)); } else { $output = array(); $input = str_split($input); } $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; } if ($k <= $bias) { $t = 1; } else if ($k >= $bias + 26) { $t = 26; } else { $t = $k - $bias; } $i += $digit * $w; $w *= 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.0100.00716.88
8.3.50.0130.01116.61
8.3.40.0090.01218.67
8.3.30.0040.01118.84
8.3.20.0030.00518.85
8.3.10.0090.00020.58
8.3.00.0050.00319.13
8.2.180.0040.01116.88
8.2.170.0090.00622.96
8.2.160.0170.00321.02
8.2.150.0060.00324.18
8.2.140.0050.00324.66
8.2.130.0080.00026.16
8.2.120.0000.00720.83
8.2.110.0100.00020.86
8.2.100.0110.00017.91
8.2.90.0040.00417.88
8.2.80.0030.00618.89
8.2.70.0040.00417.63
8.2.60.0000.00817.63
8.2.50.0060.00317.93
8.2.40.0040.00418.18
8.2.30.0030.00718.22
8.2.20.0050.00317.91
8.2.10.0080.00017.79
8.2.00.0050.00317.75
8.1.280.0180.00025.92
8.1.270.0040.00424.66
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0080.00319.37
8.1.230.0000.01220.88
8.1.220.0080.00018.68
8.1.210.0000.00818.77
8.1.200.0040.00417.48
8.1.190.0060.00317.36
8.1.180.0030.00618.10
8.1.170.0040.00417.62
8.1.160.0050.00218.89
8.1.150.0040.00418.65
8.1.140.0030.00517.39
8.1.130.0000.00717.88
8.1.120.0040.00417.52
8.1.110.0040.00417.50
8.1.100.0000.00717.40
8.1.90.0000.00917.56
8.1.80.0040.00417.51
8.1.70.0000.00717.49
8.1.60.0040.00417.61
8.1.50.0070.00017.54
8.1.40.0000.00917.60
8.1.30.0000.00817.59
8.1.20.0000.00717.61
8.1.10.0030.00617.64
8.1.00.0060.00617.54
8.0.300.0060.00318.77
8.0.290.0000.00816.88
8.0.280.0050.00318.46
8.0.270.0000.00817.32
8.0.260.0000.00717.00
8.0.250.0030.00517.06
8.0.240.0000.00917.04
8.0.230.0030.00617.07
8.0.220.0000.00717.02
8.0.210.0070.00016.98
8.0.200.0030.00317.03
8.0.190.0000.00917.00
8.0.180.0000.00717.00
8.0.170.0000.00916.92
8.0.160.0000.00717.04
8.0.150.0090.00016.97
8.0.140.0000.00816.98
8.0.130.0000.00513.45
8.0.120.0000.00816.89
8.0.110.0050.00217.02
8.0.100.0040.00417.02
8.0.90.0000.00917.06
8.0.80.0090.00517.04
8.0.70.0000.00816.88
8.0.60.0070.00016.85
8.0.50.0000.00817.13
8.0.30.0080.01117.21
8.0.20.0060.01317.27
8.0.10.0020.00517.16
8.0.00.0090.01416.95
7.4.330.0000.00513.03
7.4.320.0000.00716.62
7.4.300.0000.00616.56
7.4.290.0030.00316.60
7.4.280.0040.00416.66
7.4.270.0040.00416.54
7.4.260.0000.00713.39
7.4.250.0040.00416.44
7.4.240.0050.00216.51
7.4.230.0040.00416.75
7.4.220.0070.01016.61
7.4.210.0090.00616.60
7.4.200.0080.00016.45
7.4.190.0000.00716.41
7.4.160.0170.00316.46
7.4.150.0090.00916.60
7.4.140.0090.00816.64
7.4.130.0140.00516.66
7.4.120.0050.01316.65
7.4.110.0100.00716.54
7.4.100.0100.00716.68
7.4.90.0080.00916.49
7.4.80.0130.01019.39
7.4.70.0080.00816.44
7.4.60.0170.00016.64
7.4.50.0000.01216.63
7.4.40.0030.01216.46
7.4.30.0120.00316.69
7.4.00.0100.00715.11
7.3.330.0040.00413.31
7.3.320.0000.00513.30
7.3.310.0000.00716.44
7.3.300.0030.00316.47
7.3.290.0000.01416.43
7.3.280.0130.00616.46
7.3.270.0140.00716.47
7.3.260.0090.01216.48
7.3.250.0030.01616.51
7.3.240.0140.00316.54
7.3.230.0100.00616.48
7.3.210.0060.01216.54
7.3.200.0100.00616.38
7.3.190.0100.01316.50
7.3.180.0100.01016.49
7.3.170.0130.00316.54
7.3.160.0120.00416.57
7.3.120.0030.01014.92
7.3.10.0070.00516.59
7.3.00.0010.00916.53
7.2.330.0080.00916.82
7.2.320.0090.00916.81
7.2.310.0100.01216.80
7.2.300.0040.01416.81
7.2.290.0080.00916.64
7.2.130.0070.01016.71
7.2.120.0100.00316.83
7.2.110.0110.00516.65
7.2.100.0060.01016.47
7.2.90.0090.00416.87
7.2.80.0030.00916.73
7.2.70.0030.01216.89
7.2.60.0050.01116.81
7.2.50.0060.00616.72
7.2.40.0090.00616.80
7.2.30.0040.01116.89
7.2.20.0070.00316.87
7.2.10.0060.00816.81
7.2.00.0030.01117.80
7.1.250.0040.01015.60
7.1.100.0060.00617.99
7.1.70.0030.00517.12
7.1.60.0040.01819.40
7.1.50.0000.02216.96
7.1.00.0070.06022.25
7.0.200.0050.00516.64
7.0.140.0000.07721.93
7.0.120.0000.07722.02
7.0.60.0130.08019.88
7.0.50.0030.04317.87
7.0.40.0070.08320.23
7.0.30.0570.07320.07
7.0.20.0230.06720.24
7.0.10.0270.03020.20
7.0.00.0070.08020.20
5.6.280.0030.07321.05
5.6.210.0070.04320.56
5.6.200.0000.04718.25
5.6.190.0030.09020.54
5.6.180.0170.08320.61
5.6.170.0170.05020.56
5.6.160.0100.07720.55
5.6.150.0070.05718.18
5.6.140.0030.06718.17
5.6.130.0070.08318.24
5.6.120.0130.08021.03
5.6.110.0070.04721.03
5.6.100.0070.08021.02
5.6.90.0170.07721.15
5.6.80.0070.03720.41
5.6.70.0170.04320.36
5.5.350.0300.07320.41
5.5.340.0000.07317.96
5.5.330.0100.04720.18
5.5.320.0070.04320.41
5.5.310.0300.06720.29
5.5.300.0100.08017.96
5.5.290.0100.06017.97
5.5.280.0170.07320.80
5.5.270.0070.08320.79
5.5.260.0030.07320.79
5.5.250.0000.04320.60
5.5.240.0070.07320.35
5.4.450.0170.04019.45
5.4.440.0070.04319.47
5.4.430.0070.06019.42
5.4.420.0070.07019.56
5.4.410.0030.05019.35
5.4.400.0030.04719.01
5.4.390.0070.03719.14
5.4.380.0100.04019.14
5.4.370.0100.03719.00
5.4.360.0130.07319.14
5.4.350.0100.07719.16
5.4.340.0030.08318.85
5.4.320.0000.04719.12
5.4.310.0030.04719.14
5.4.300.0000.07719.00
5.4.290.0070.08019.12
5.4.280.0100.07719.15
5.4.270.0070.06718.92
5.4.260.0100.04319.11
5.4.250.0000.04018.97
5.4.240.0000.04018.91
5.4.230.0070.03319.04
5.4.220.0070.03319.07
5.4.210.0000.04019.14
5.4.200.0030.04019.16
5.4.190.0030.03719.23
5.4.180.0070.03719.09
5.4.170.0000.04019.23
5.4.160.0070.03719.05
5.4.150.0030.04019.12
5.4.140.0000.03716.51
5.4.130.0000.03716.39
5.4.120.0070.03016.34
5.4.110.0030.03316.43
5.4.100.0100.02716.48
5.4.90.0030.03716.40
5.4.80.0030.04016.42
5.4.70.0000.03716.65
5.4.60.0070.03316.38
5.4.50.0030.03716.41
5.4.40.0030.03716.44
5.4.30.0000.04016.36
5.4.20.0000.03716.64
5.4.10.0030.03716.46
5.4.00.0030.03315.87
5.3.290.0030.04014.71
5.3.280.0030.03714.64
5.3.270.0030.04714.70
5.3.260.0130.02714.65
5.3.250.0030.03714.70
5.3.240.0030.04014.64
5.3.230.0000.04314.66
5.3.220.0000.04314.49
5.3.210.0030.04014.60
5.3.200.0030.03714.61
5.3.190.0000.04014.60
5.3.180.0000.04014.60
5.3.170.0130.02714.59
5.3.160.0000.04014.65
5.3.150.0100.03314.63
5.3.140.0070.03314.60
5.3.130.0030.04014.58
5.3.120.0030.04014.50
5.3.110.0030.03714.59
5.3.100.0030.04314.23
5.3.90.0000.03714.11
5.3.80.0100.03013.94
5.3.70.0130.02714.13
5.3.60.0000.03714.08
5.3.50.0030.03314.04
5.3.40.0000.04014.14
5.3.30.0100.04014.09
5.3.20.0030.04013.76
5.3.10.0100.03713.71
5.3.00.0030.06013.73
5.2.170.0100.02711.16
5.2.160.0070.03011.19
5.2.150.0030.03011.18
5.2.140.0030.03311.13
5.2.130.0030.02711.16
5.2.120.0000.05311.11
5.2.110.0000.03311.20
5.2.100.0070.05011.12
5.2.90.0000.03311.14
5.2.80.0170.02311.05
5.2.70.0030.03311.06
5.2.60.0100.04311.01
5.2.50.0070.06311.07
5.2.40.0100.05311.05
5.2.30.0030.04310.93
5.2.20.0000.03310.92
5.2.10.0070.03710.95
5.2.00.0070.05710.74
5.1.60.0030.04710.05
5.1.50.0070.0379.95
5.1.40.0030.0279.99
5.1.30.0030.05710.37
5.1.20.0030.03710.44
5.1.10.0030.0279.94
5.1.00.0030.0509.90
5.0.50.0030.0208.66
5.0.40.0030.0478.37
5.0.30.0130.0578.43
5.0.20.0030.0238.20
5.0.10.0130.0338.20
5.0.00.0000.0378.23
4.4.90.0070.0308.20
4.4.80.0000.0378.20
4.4.70.0070.0338.20
4.4.60.0100.0308.20
4.4.50.0000.0208.20
4.4.40.0000.0538.20
4.4.30.0070.0278.20
4.4.20.0070.0338.20
4.4.10.0000.0238.20
4.4.00.0170.0278.20
4.3.110.0070.0308.20
4.3.100.0070.0308.20
4.3.90.0030.0338.20
4.3.80.0100.0378.20
4.3.70.0000.0378.20
4.3.60.0000.0308.20
4.3.50.0030.0338.20
4.3.40.0000.0378.20
4.3.30.0030.0338.20
4.3.20.0070.0338.20
4.3.10.0030.0338.20
4.3.00.0070.0308.20

preferences:
64.55 ms | 401 KiB | 5 Q