3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class IDN { private function adaptBias($delta, $numpoints, $first) { $delta = $first ? $delta / 700 : $delta / 2; $delta += $delta / $numPoints; for ($k = 0; $delta > 455; $k += 36) { $delta = (int)($delta / 35); } return $k + (36 * $delta) / ($delta + 38); } private function encodeUtf8CodePoint($codePoint) { switch (true) { case $codePoint < 0x80: return pack('C*', $codePoint & 0x7F); case $codePoint < 0x0800: return pack('C*', (($codePoint & 0x07C0) >> 6) | 0xC0, ($codePoint & 0x3F) | 0x80); case $codePoint < 0x010000: return pack('C*', (($codePoint & 0xF000) >> 12) | 0xE0, (($codePoint & 0x0FC0) >> 6) | 0x80, ($codePoint & 0x3F) | 0x80); case $codePoint < 0x110000: return pack('C*', (($codePoint & 0x1C0000) >> 18) | 0xF0, (($codePoint & 0x03F000) >> 12) | 0x80, (($codePoint & 0x0FC0) >> 6) | 0x80, ($codePoint & 0x3F) | 0x80); } return false; } public 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); $nonBasicChars = substr($input, $nonBasicCharsStart + 1); } else { $output = []; $nonBasicChars = $input; } $n = 128; $i = 0; $bias = 72; for ($j = 0, $l = strlen($nonBasicChars); $j < $l; $i++) { $oldi = $i; $w = 1; $k = 36; while (true) { if (!isset($nonBasicChars[$j])) { return false; } $digit = ord($nonBasicChars[$j++]); 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; } $c = count($output) + 1; $bias = $this->adaptBias($i - $oldi, $c, $oldi === 0); $n += (int)($i / $c); $i %= $c; array_splice($output, $i, 0, array($this->encodeUtf8CodePoint($n))); } return implode('', $output); } public function decodeIDN($name) { // split it, parse it and put it back together return implode( ".", array_map([$this, 'decodePart'],explode(".",$name)) ); } } echo (new 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).
Note: hhvm uses a JIT which only kicks in after a few runs. Since we run scripts only once, hhvm always runs slower.

VersionSystem time (s)User time (s)Memory (MiB)
7.2.60.0030.01016.98
7.2.00.0090.00919.47
7.1.200.0100.00315.87
7.1.100.0000.01118.02
7.1.70.0030.00517.33
7.1.60.0150.00319.82
7.1.50.0070.01416.92
7.1.00.0070.04722.45
7.0.200.0000.00816.78
7.0.140.0030.07022.18
7.0.100.0300.07320.11
7.0.90.0430.07719.95
7.0.80.0270.09320.02
7.0.70.0370.08320.19
7.0.60.0330.06720.09
7.0.50.0370.07720.36
7.0.40.0100.07320.19
7.0.30.0030.08320.00
7.0.20.0030.08319.98
7.0.10.0100.08020.13
7.0.00.0030.07020.18
5.6.280.0030.07021.05
5.6.250.0170.07320.66
5.6.240.0070.08720.70
5.6.230.0030.08320.66
5.6.220.0130.07320.61
5.6.210.0130.05320.70
5.6.200.0130.08320.97
5.6.190.0000.08720.97
5.6.180.0070.08721.07
5.6.170.0130.07720.99
5.6.160.0130.08021.11
5.6.150.0030.09021.05
5.6.140.0200.07721.04
5.6.130.0030.09020.96
5.6.120.0100.08021.03
5.6.110.0130.07020.96
5.6.100.0130.06721.14
5.6.90.0170.07321.11
5.6.80.0030.08320.41
5.6.70.0130.07720.49
5.6.60.0000.08320.41
5.6.50.0100.08020.49
5.6.40.0100.07720.50
5.6.30.0100.06720.48
5.6.20.0100.04320.39
5.6.10.0100.07720.41
5.6.00.0270.06320.45
5.5.380.0130.07720.46
5.5.370.0100.04320.39
5.5.360.0130.06720.39
5.5.350.0000.07320.34
5.5.340.0200.06320.90
5.5.330.0070.08720.67
5.5.320.0130.04720.77
5.5.310.0070.07320.76
5.5.300.0100.08720.75
5.5.290.0130.07720.92
5.5.280.0070.08720.79
5.5.270.0100.08320.90
5.5.260.0130.07320.84
5.5.250.0200.07020.64
5.5.240.0070.07320.32
5.5.230.0070.08020.29
5.5.220.0030.08320.29
5.5.210.0100.07720.21
5.5.200.0130.07020.03
5.5.190.0100.07720.30
5.5.180.0030.08020.21
5.5.160.0130.07320.18
5.5.150.0070.05020.15
5.5.140.0030.08020.30
5.5.130.0130.07320.30
5.5.120.0100.06020.02
5.5.110.0070.08020.13
5.5.100.0130.07320.20
5.5.90.0070.07320.11
5.5.80.0030.05020.13
5.5.70.0100.07720.18
5.5.60.0070.08020.18
5.5.50.0070.08019.96
5.5.40.0030.04720.12
5.5.30.0000.04720.11
5.5.20.0070.03720.11
5.5.10.0070.04320.05
5.5.00.0030.04720.11
5.4.450.0130.07719.18
5.4.440.0030.08319.47
5.4.430.0100.07019.37
5.4.420.0100.07719.53
5.4.410.0130.07319.36
5.4.400.0130.07019.21
5.4.390.0070.07719.05
5.4.380.0100.07319.16
5.4.370.0100.07019.03
5.4.360.0070.07319.25
5.4.350.0100.07319.04
5.4.340.0100.07718.88
5.4.320.0170.05318.86
5.4.310.0200.06319.13
5.4.300.0170.06319.07
5.4.290.0070.07319.03
5.4.280.0070.08019.23
5.4.270.0070.07019.13
5.4.260.0170.06719.12
5.4.250.0070.08019.24
5.4.240.0100.06019.04
5.4.230.0030.05718.86
5.4.220.0070.07319.13
5.4.210.0030.06319.09
5.4.200.0100.05019.20
5.4.190.0030.04718.99
5.4.180.0070.04019.13
5.4.170.0100.03318.93
5.4.160.0070.03718.98
5.4.150.0070.04019.08
5.4.140.0030.03716.32
5.4.130.0000.03716.44
5.4.120.0030.03716.37
5.4.110.0000.03716.37
5.4.100.0000.03716.44
5.4.90.0000.03716.30
5.4.80.0000.06316.33
5.4.70.0030.03716.45
5.4.60.0070.04716.48
5.4.50.0030.06016.35
5.4.40.0030.05716.46
5.4.30.0030.05016.32
5.4.20.0000.05016.46
5.4.10.0030.06016.35
5.4.00.0000.03715.79
5.3.290.0030.07714.70
5.3.280.0100.04014.77
5.3.270.0070.04314.73
5.3.260.0070.04014.77
5.3.250.0070.03314.56
5.3.240.0000.04314.68
5.3.230.0000.04014.76
5.3.220.0030.03314.52
5.3.210.0030.03714.61
5.3.200.0070.03314.57
5.3.190.0070.04014.64
5.3.180.0030.03714.71
5.3.170.0030.04314.57
5.3.160.0030.03714.65
5.3.150.0030.03714.71
5.3.140.0030.03714.57
5.3.130.0030.04014.58
5.3.120.0070.03314.62
5.3.110.0070.05014.63
5.3.100.0000.04714.16
5.3.90.0130.02314.17
5.3.80.0000.04014.05
5.3.70.0100.03314.09
5.3.60.0030.06314.13
5.3.50.0030.03713.89
5.3.40.0000.04313.86
5.3.30.0000.03713.96
5.3.20.0000.03713.85
5.3.10.0000.04713.81
5.3.00.0100.03013.54
5.2.170.0030.02712.07
5.2.160.0030.03712.07
5.2.150.0000.03312.07
5.2.140.0030.04712.07
5.2.130.0100.04712.07
5.2.120.0000.04012.07
5.2.110.0030.03312.07
5.2.100.0000.05312.07
5.2.90.0070.02312.07
5.2.80.0000.05712.07
5.2.70.0000.03012.07
5.2.60.0100.02012.07
5.2.50.0000.03012.07
5.2.40.0000.04312.07
5.2.30.0030.03012.07
5.2.20.0030.02712.07
5.2.10.0000.03012.07
5.2.00.0030.02712.07
5.1.60.0070.03012.07
5.1.50.0000.03712.07
5.1.40.0070.04012.07
5.1.30.0030.02712.07
5.1.20.0000.03012.07
5.1.10.0000.02712.07
5.1.00.0100.02712.07
5.0.50.0030.02012.07
5.0.40.0000.02012.07
5.0.30.0000.06712.07
5.0.20.0030.04012.07
5.0.10.0030.03312.07
5.0.00.0030.04712.07
4.4.90.0000.03012.07
4.4.80.0000.01712.07
4.4.70.0000.01712.07
4.4.60.0000.01712.07
4.4.50.0000.01712.07
4.4.40.0000.02312.07
4.4.30.0000.01712.07
4.4.20.0000.01312.07
4.4.10.0000.01712.07
4.4.00.0000.02312.07
4.3.110.0000.02012.07
4.3.100.0000.01712.07
4.3.90.0030.03712.07
4.3.80.0030.05012.07
4.3.70.0030.02712.07
4.3.60.0070.02712.07
4.3.50.0000.03312.07
4.3.40.0030.03012.07
4.3.30.0000.03312.07
4.3.20.0000.03712.07
4.3.10.0030.03312.07
4.3.00.0070.03012.07