3v4l.org

run code in 300+ PHP versions simultaneously
<?PHP class InvalidStateException extends RuntimeException { } class Compiler { private $ptr; private $arr; private $code; private $commands = array('>', '<', '+', '-', '.', ',', '[', ']'); private $call_stack = array(); private $cellsize = 8; public function parseString($code, $throwException = true) { $this->code = $code; for ($i=0;$i<strlen($this->code);$i++) { $c = substr($this->code, $i, 1); if (!in_array($c, $this->commands)) { continue; } } } public function execute($code) { $this->arr = array(0 => 0); $this->ptr = 0; $this->code = $code; for ($this->i=0;$this->i<strlen($this->code);$this->i++) { $c = $this->c = substr($this->code, $this->i, 1); if (!in_array($c, $this->commands)) { continue; } elseif ($c == '>') { $this->increment_pointer(); } elseif ($c == '<') { $this->decrement_pointer(); } elseif ($c == '+') { $this->increment_val(); } elseif ($c == '-') { $this->decrement_val(); } elseif ($c == '.') { $this->output_val(); } elseif ($c == ',') { $this->store_val($this->input_val()); } elseif ($c == '[') { $this->loop($this->i); } } } private function stack($func) { if (is_null($func)) { if (count($this->call_stack) == 0) { throw new InvalidStateException("Trying to pop empty call stack."); return false; } array_pop($this->call_stack); return true; } else { $info = array('command' => $this->c, 'pos' => $this->i, 'internal_function' => $func); array_push($this->call_stack, $info); return true; } } public function minimum_cellsize() { return (-1*(pow(2, $this->cellsize-1))); } public function maximum_cellsize() { return pow(2, $this->cellsize-1)-1; } private function increment_pointer() { $this->stack(__FUNCTION__); $this->ptr++; if (!isset($this->arr[$this->ptr])) $this->arr[$this->ptr] = 0; $this->stack(); return true; } private function decrement_pointer() { $this->stack(__FUNCTION__); $this->ptr--; if ($this->ptr < 0) { throw new IllegalStateException("The data pointer is less than 0."); return false; } $this->stack(); return true; } private function increment_val() { $x = $this->arr[$this->ptr]++; if ($x < $this->minimum_cellsize()) { $this->arr[$this->ptr] = $this->maximum_cellsize(); } elseif ($x > $this->maximum_cellsize()) { $this->arr[$this->ptr] = $this->minimum_cellsize(); } return true; } public function getCallStack() { return $this->call_stack; } } $c = new Compiler(); $bf = '+++++++++ +++++++++ +++++++++ + > +++++++++ +++++++++ +++++++++ ++ < . < .'; $c->execute($bf); ?>

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.0060.01518.43
8.3.50.0110.00721.14
8.3.40.0060.00919.09
8.3.30.0040.01120.21
8.3.20.0070.00020.20
8.3.10.0050.00322.05
8.3.00.0000.00820.58
8.2.180.0110.00416.75
8.2.170.0090.00622.96
8.2.160.0110.00320.33
8.2.150.0050.00324.18
8.2.140.0100.01024.66
8.2.130.0060.00326.16
8.2.120.0080.00019.67
8.2.110.0070.00422.27
8.2.100.0100.00618.28
8.2.90.0000.00817.90
8.2.80.0000.00918.16
8.2.70.0030.00618.04
8.2.60.0000.00818.28
8.2.50.0060.00318.10
8.2.40.0080.00020.35
8.2.30.0040.00419.43
8.2.20.0080.00017.91
8.2.10.0080.00017.80
8.2.00.0070.00317.85
8.1.280.0120.00825.92
8.1.270.0070.00024.66
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0030.00620.64
8.1.230.0040.00721.04
8.1.220.0030.00517.91
8.1.210.0040.00418.77
8.1.200.0040.00417.60
8.1.190.0060.00317.35
8.1.180.0000.00818.10
8.1.170.0000.00819.02
8.1.160.0000.00718.93
8.1.150.0000.00720.13
8.1.140.0070.00017.62
8.1.130.0000.00717.76
8.1.120.0000.00717.52
8.1.110.0030.00517.48
8.1.100.0000.00717.54
8.1.90.0000.00717.58
8.1.80.0040.00417.48
8.1.70.0000.00717.45
8.1.60.0030.00617.65
8.1.50.0000.00817.60
8.1.40.0080.00017.61
8.1.30.0040.00417.58
8.1.20.0060.00317.68
8.1.10.0040.00417.61
8.1.00.0030.00617.55
8.0.300.0040.00421.51
8.0.290.0040.00417.00
8.0.280.0000.00818.50
8.0.270.0070.00017.21
8.0.260.0000.00717.00
8.0.250.0030.00317.06
8.0.240.0000.00817.00
8.0.230.0040.00416.96
8.0.220.0070.00016.97
8.0.210.0050.00217.04
8.0.200.0030.00316.94
8.0.190.0000.00716.95
8.0.180.0050.00516.93
8.0.170.0070.00017.06
8.0.160.0050.00217.05
8.0.150.0070.00017.00
8.0.140.0000.00716.96
8.0.130.0000.00613.47
8.0.120.0060.00316.89
8.0.110.0020.00516.93
8.0.100.0000.00716.86
8.0.90.0020.00517.02
8.0.80.0110.00416.96
8.0.70.0030.00516.88
8.0.60.0000.00717.12
8.0.50.0000.00816.88
8.0.30.0130.00616.99
8.0.20.0160.00617.40
8.0.10.0000.00717.02
8.0.00.0120.00616.97
7.4.330.0000.00515.00
7.4.320.0060.00016.72
7.4.300.0000.00616.66
7.4.290.0000.00716.55
7.4.280.0030.00316.64
7.4.270.0030.00316.59
7.4.260.0000.00716.64
7.4.250.0000.00816.66
7.4.240.0050.00216.57
7.4.230.0070.00016.50
7.4.220.0100.01016.65
7.4.210.0060.01016.71
7.4.200.0000.00716.64
7.4.190.0040.00416.52
7.4.160.0130.00316.48
7.4.150.0120.00617.40
7.4.140.0080.00917.86
7.4.130.0080.01016.62
7.4.120.0130.00716.66
7.4.110.0150.00316.75
7.4.100.0040.01416.41
7.4.90.0180.00616.56
7.4.80.0130.00919.39
7.4.70.0070.01416.37
7.4.60.0160.00016.68
7.4.50.0040.00016.39
7.4.40.0070.00722.77
7.4.30.0050.01516.57
7.4.00.0070.00715.06
7.3.330.0030.00313.49
7.3.320.0000.00613.45
7.3.310.0030.00516.50
7.3.300.0040.00416.46
7.3.290.0060.01316.49
7.3.280.0130.00516.49
7.3.270.0070.01017.40
7.3.260.0170.00016.56
7.3.250.0090.00716.53
7.3.240.0070.01016.51
7.3.230.0130.00316.48
7.3.210.0090.01216.48
7.3.200.0110.01119.39
7.3.190.0120.00516.70
7.3.180.0100.01016.49
7.3.170.0060.01016.46
7.3.160.0000.02016.47
7.3.120.0040.01214.92
7.2.330.0150.00316.89
7.2.320.0100.00716.71
7.2.310.0100.00716.84
7.2.300.0060.01016.64
7.2.290.0070.01116.83
7.2.60.0070.01017.15
7.2.00.0090.00319.41
7.1.200.0070.00715.98
7.1.100.0100.00718.04
7.1.70.0000.01017.28
7.1.60.0140.01119.21
7.1.50.0100.01016.68
7.1.00.0070.03022.57
7.0.200.0310.00014.88
7.0.140.0030.07322.13
7.0.60.0070.05019.99
7.0.50.0030.07717.77
7.0.40.0030.08720.13
7.0.30.0330.07020.12
7.0.20.0330.05720.18
7.0.10.0130.04320.22
7.0.00.0030.06320.20
5.6.280.0000.07320.84
5.6.210.0130.08320.57
5.6.200.0070.08318.29
5.6.190.0070.08320.41
5.6.180.0200.03720.77
5.6.170.0200.04320.44
5.6.160.0130.06020.57
5.6.150.0070.03718.28
5.6.140.0030.06018.17
5.6.130.0030.08318.17
5.6.120.0030.06321.02
5.6.110.0070.06021.03
5.6.100.0230.06721.08
5.6.90.0070.08021.02
5.6.80.0030.06020.39
5.6.70.0200.07020.56
5.5.350.0130.06020.42
5.5.340.0030.08318.09
5.5.330.0030.08020.35
5.5.320.0170.04720.27
5.5.310.0270.08320.27
5.5.300.0070.05717.98
5.5.290.0030.08718.04
5.5.280.0170.06020.68
5.5.270.0070.08720.91
5.5.260.0070.07721.00
5.5.250.0070.07020.73
5.5.240.0100.06720.38
5.4.450.0830.05719.20
5.4.440.0670.06019.47
5.4.430.0830.07319.48
5.4.420.0430.06019.60
5.4.410.1000.07719.50
5.4.400.0270.06018.57
5.4.390.0370.05718.78
5.4.380.0200.05718.76
5.4.370.0270.05718.76
5.4.360.0270.05718.61
5.4.350.0050.04212.06
5.4.340.0060.04312.05
5.4.320.0040.04212.54
5.4.310.0050.04312.54
5.4.300.0050.05312.54
5.4.290.0050.04612.54
5.4.280.0070.04212.43
5.4.270.0040.03812.43
5.4.260.0060.03712.43
5.4.250.0100.06018.66
5.4.240.0130.06718.80
5.4.230.0170.05318.75
5.4.220.0130.07018.95
5.4.210.0130.04718.95
5.4.200.0130.05318.63
5.4.190.0100.07018.79
5.4.180.0070.08018.90
5.4.170.0070.05718.93
5.4.160.0100.07318.82
5.4.150.0100.05719.08
5.4.140.0170.06316.35
5.4.130.0070.04716.34
5.4.120.0100.05016.48
5.4.110.0070.05716.55
5.4.100.0170.05316.72
5.4.90.0130.04016.46
5.4.80.0130.06716.43
5.4.70.0170.06716.59
5.4.60.0230.07016.51
5.4.50.0030.05716.64
5.4.40.0000.05716.50
5.4.30.0230.05316.51
5.4.20.0130.04716.61
5.4.10.0170.04316.46
5.4.00.0130.04715.99
5.3.290.0060.05512.80
5.3.280.0100.05014.73
5.3.270.0100.06714.64
5.3.260.0030.05714.73
5.3.250.0170.04314.50
5.3.240.0130.04714.64
5.3.230.0030.05314.72
5.3.220.0070.05014.63
5.3.210.0100.05014.59
5.3.200.0070.05014.44
5.3.190.0130.04714.58
5.3.180.0070.05014.59
5.3.170.0100.07314.79
5.3.160.0200.04314.74
5.3.150.0130.05314.57
5.3.140.0100.05014.76
5.3.130.0200.06714.59
5.3.120.0100.05314.66
5.3.110.0100.05014.42
5.3.100.0200.06714.24
5.3.90.0100.04714.14
5.3.80.0230.06014.05
5.3.70.0170.04013.89
5.3.60.0130.04314.02
5.3.50.0000.06314.13
5.3.40.0030.05314.22
5.3.30.0000.06313.96
5.3.20.0000.05713.83
5.3.10.0070.04713.68
5.3.00.0130.04313.77
5.2.170.0030.04311.30
5.2.160.0100.05311.18
5.2.150.0030.04711.28
5.2.140.0030.04311.14
5.2.130.0070.05311.22
5.2.120.0100.05011.23
5.2.110.0030.04311.24
5.2.100.0000.04311.11
5.2.90.0230.02311.23
5.2.80.0030.05011.32
5.2.70.0130.03311.23
5.2.60.0130.04311.19
5.2.50.0030.04311.29
5.2.40.0030.04011.22
5.2.30.0100.03711.09
5.2.20.0000.04311.09
5.2.10.0030.04311.09
5.2.00.0070.03710.74
5.1.60.0030.03310.10
5.1.50.0000.04010.14
5.1.40.0100.03710.12
5.1.30.0030.05710.42
5.1.20.0070.04310.63
5.1.10.0070.04710.21
5.1.00.0030.03710.09
5.0.50.0070.0308.66
5.0.40.0070.0238.61
5.0.30.0030.0438.36
5.0.20.0030.0278.44
5.0.10.0000.0308.29
5.0.00.0000.0438.17
4.4.90.0070.0177.42
4.4.80.0030.0207.42
4.4.70.0000.0277.42
4.4.60.0000.0237.42
4.4.50.0030.0237.42
4.4.40.0000.0407.42
4.4.30.0030.0237.42
4.4.20.0070.0207.42
4.4.10.0070.0177.42
4.4.00.0000.0377.42
4.3.110.0030.0237.42
4.3.100.0000.0307.42
4.3.90.0000.0207.42
4.3.80.0030.0307.42
4.3.70.0000.0207.42
4.3.60.0030.0177.42
4.3.50.0000.0237.42
4.3.40.0030.0407.42
4.3.30.0000.0237.42
4.3.20.0000.0237.42
4.3.10.0070.0177.42
4.3.00.0030.0276.44

preferences:
63.79 ms | 401 KiB | 5 Q