3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Bijective { /** * * @var string */ private $dictionary = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; /** * CTOR */ public function __construct() { $this->dictionary = str_split($this->dictionary); } /** * * @param int $i * @return string */ public function encode($i) { if ($i == 0) return $this->dictionary[0]; $result = ''; $base = count($this->dictionary); while ($i > 0) { $result[] = $this->dictionary[($i % $base)]; $i = floor($i / $base); } $result = array_reverse($result); return join("", $result); } /** * * @param string $input * @return int */ public function decode($input) { $i = 0; $base = count($this->dictionary); $input = str_split($input); foreach ($input as $char) { $pos = array_search($char, $this->dictionary); $i = $i * $base + $pos; } return $i; } } $b=new Bijective();

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.0110.00316.92
7.2.00.0000.01219.54
7.1.200.0000.01315.63
7.1.100.0040.00418.11
7.1.70.0030.00617.13
7.1.60.0180.00319.33
7.1.50.0100.00716.84
7.1.00.0070.07322.54
7.0.200.0040.01116.73
7.0.140.0070.06322.18
7.0.60.0000.06320.04
7.0.50.0030.05317.86
7.0.40.0070.04020.02
7.0.30.0400.05320.09
7.0.20.0400.06720.07
7.0.10.0030.09020.09
7.0.00.0100.08020.25
5.6.280.0030.09020.83
5.6.210.0130.06720.54
5.6.200.0130.06718.19
5.6.190.0000.05720.41
5.6.180.0230.04320.77
5.6.170.0270.06020.69
5.6.160.0100.08320.55
5.6.150.0100.07318.13
5.6.140.0100.07718.24
5.6.130.0100.08018.11
5.6.120.0070.08721.13
5.6.110.0070.04021.00
5.6.100.0100.03721.12
5.6.90.0130.08021.11
5.6.80.0130.07320.53
5.5.350.0270.06020.41
5.5.340.0130.08017.98
5.5.330.0030.06720.41
5.5.320.0100.07320.19
5.5.310.0170.04720.41
5.5.300.0000.05318.04
5.5.290.0100.07717.98
5.5.280.0070.04020.88
5.5.270.0130.07720.80
5.5.260.0100.08020.80
5.5.250.0070.06720.60
5.5.240.2670.02720.05
5.4.450.0300.05319.31
5.4.440.0170.05019.18
5.4.430.0400.06319.57
5.4.420.0300.07019.56
5.4.410.0330.06719.53
5.4.400.0300.06319.20
5.4.390.0230.04719.00
5.4.380.0270.06319.14
5.4.370.0270.06319.09
5.4.360.0270.04319.06
5.4.350.0330.06319.20
5.4.340.0370.06319.20
5.4.320.0300.06319.26
5.4.310.0270.03319.22
5.4.300.0330.04719.07
5.4.290.0430.06318.95
5.4.280.0370.04019.22
5.4.270.0370.06318.94
5.4.260.0370.06019.16
5.4.250.0370.05719.05
5.4.240.0270.03318.86
5.4.230.0370.06319.07
5.4.220.0330.03319.19
5.4.210.0370.04019.09
5.4.200.0300.04018.84
5.4.190.0270.03019.07
5.4.180.0230.04318.97
5.4.170.0130.04319.07
5.4.160.0170.03719.18
5.4.150.0130.04018.85
5.4.140.0200.03316.38
5.4.130.0230.03016.28
5.4.120.0230.03316.35
5.4.110.0170.03716.45
5.4.100.0170.04016.59
5.4.90.0230.04016.37
5.4.80.0230.03016.25
5.4.70.0200.03716.35
5.4.60.0200.03316.54
5.4.50.0200.03316.17
5.4.40.0300.03316.58
5.4.30.0230.03016.32
5.4.20.0270.02716.57
5.4.10.0170.03316.42
5.4.00.0170.03315.95
5.3.290.0330.05714.59
5.3.280.0330.06714.69
5.3.270.0230.03314.63
5.3.260.0200.03714.66
5.3.250.0200.03314.59
5.3.240.0100.04014.78
5.3.230.0270.03314.60
5.3.220.0200.04714.66
5.3.210.0230.03014.58
5.3.200.0230.03014.66
5.3.190.0170.04314.48
5.3.180.0130.04014.59
5.3.170.0170.03714.69
5.3.160.0100.04314.51
5.3.150.0100.05014.49
5.3.140.0170.04014.72
5.3.130.0170.03714.58
5.3.120.0270.02714.63
5.3.110.0200.04314.68
5.3.100.0130.04014.05
5.3.90.0170.03713.96
5.3.80.0230.03013.95
5.3.70.0200.03314.21
5.3.60.0100.04313.91
5.3.50.0200.03014.00
5.3.40.0170.03313.88
5.3.30.0130.04014.04
5.3.20.0230.03713.75
5.3.10.0330.04313.89
5.3.00.0300.06013.77
5.2.170.0130.03012.05
5.2.160.0100.03012.05
5.2.150.0200.03012.05
5.2.140.0130.03012.05
5.2.130.0200.05712.05
5.2.120.0200.03712.05
5.2.110.0170.04012.05
5.2.100.0130.03312.05
5.2.90.0270.04712.05
5.2.80.0230.03712.05
5.2.70.0170.04012.05
5.2.60.0170.03312.05
5.2.50.0200.06012.05
5.2.40.0170.04712.05
5.2.30.0200.05712.05
5.2.20.0200.04712.05
5.2.10.0230.04312.05
5.2.00.0170.04712.05
5.1.60.0200.03012.05
5.1.50.0130.05712.05
5.1.40.0300.02012.05
5.1.30.0270.05012.05
5.1.20.0230.05012.05
5.1.10.0200.04012.05
5.1.00.0170.05312.05
5.0.50.0070.04712.05
5.0.40.0100.04312.05
5.0.30.0130.03312.05
5.0.20.0130.03712.05
5.0.10.0130.01712.05
5.0.00.0170.05012.05
4.4.90.0070.01712.05
4.4.80.0070.03712.05
4.4.70.0130.02012.05
4.4.60.0070.03012.05
4.4.50.0070.03712.05
4.4.40.0130.05012.05
4.4.30.0070.02312.05
4.4.20.0100.02312.05
4.4.10.0070.02712.05
4.4.00.0100.05012.05
4.3.110.0070.02712.05
4.3.100.0070.03712.05
4.3.90.0130.03012.05
4.3.80.0130.05312.05
4.3.70.0100.02712.05
4.3.60.0100.03312.05
4.3.50.0100.03712.05
4.3.40.0130.04312.05
4.3.30.0030.02712.05
4.3.20.0070.02012.05
4.3.10.0100.02712.05
4.3.00.0070.03012.05