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(); const 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; } } 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.0140.00718.43
8.3.50.0040.01522.04
8.3.40.0140.00718.91
8.3.30.0100.00320.34
8.3.20.0000.00720.34
8.3.10.0040.00422.15
8.3.00.0080.00020.57
8.2.180.0070.00716.63
8.2.170.0150.00022.96
8.2.160.0070.00720.48
8.2.150.0080.00024.18
8.2.140.0160.00324.66
8.2.130.0030.00526.16
8.2.120.0040.00419.79
8.2.110.0060.00322.09
8.2.100.0100.00319.28
8.2.90.0030.00619.36
8.2.80.0040.00419.32
8.2.70.0000.00817.88
8.2.60.0050.00317.90
8.2.50.0080.00018.07
8.2.40.0040.00418.34
8.2.30.0040.00418.18
8.2.20.0000.00717.77
8.2.10.0030.00517.86
8.2.00.0090.00317.81
8.1.280.0110.01125.92
8.1.270.0080.00024.66
8.1.260.0090.00026.35
8.1.250.0030.00528.09
8.1.240.0040.00723.96
8.1.230.0070.00319.27
8.1.220.0000.00817.78
8.1.210.0040.00418.77
8.1.200.0000.01017.47
8.1.190.0040.00417.63
8.1.180.0000.00819.13
8.1.170.0000.00818.67
8.1.160.0000.00722.12
8.1.150.0030.00618.70
8.1.140.0000.00817.47
8.1.130.0000.00717.93
8.1.120.0000.00717.55
8.1.110.0040.00417.40
8.1.100.0070.00017.56
8.1.90.0040.00417.55
8.1.80.0000.00717.43
8.1.70.0050.00317.41
8.1.60.0030.00617.61
8.1.50.0040.00417.59
8.1.40.0060.00317.62
8.1.30.0030.00517.71
8.1.20.0040.00417.71
8.1.10.0060.00317.53
8.1.00.0040.00817.52
8.0.300.0000.00818.77
8.0.290.0000.00817.30
8.0.280.0030.00518.52
8.0.270.0040.00417.25
8.0.260.0000.00716.89
8.0.250.0030.00316.99
8.0.240.0060.00317.08
8.0.230.0000.00717.09
8.0.220.0030.00317.05
8.0.210.0070.00017.00
8.0.200.0050.00316.96
8.0.190.0050.00217.07
8.0.180.0120.00017.07
8.0.170.0040.00417.05
8.0.160.0000.00717.06
8.0.150.0020.00517.02
8.0.140.0040.00416.97
8.0.130.0060.00013.39
8.0.120.0030.00616.81
8.0.110.0040.00416.92
8.0.100.0080.00017.00
8.0.90.0030.00516.90
8.0.80.0100.00616.91
8.0.70.0040.00416.93
8.0.60.0070.00017.03
8.0.50.0070.00016.92
8.0.30.0110.00717.08
8.0.20.0150.00517.47
8.0.10.0040.00417.03
8.0.00.0110.00616.73
7.4.330.0060.00315.00
7.4.320.0000.00616.70
7.4.300.0000.00616.54
7.4.290.0070.00016.68
7.4.280.0040.00416.65
7.4.270.0030.00316.72
7.4.260.0070.00016.66
7.4.250.0070.00016.53
7.4.240.0040.00316.70
7.4.230.0000.00716.66
7.4.220.0060.01216.56
7.4.210.0020.01216.62
7.4.200.0030.00316.41
7.4.190.0000.00716.51
7.4.160.0070.01016.82
7.4.150.0030.01417.40
7.4.140.0110.01117.86
7.4.130.0100.00716.54
7.4.120.0150.00416.52
7.4.110.0130.01016.57
7.4.100.0120.01216.63
7.4.90.0110.00716.78
7.4.80.0060.01019.39
7.4.70.0110.00716.36
7.4.60.0070.01016.61
7.4.50.0000.00416.21
7.4.40.0040.01522.77
7.4.30.0080.01216.62
7.4.00.0100.00714.98
7.3.330.0000.00613.48
7.3.320.0060.00013.29
7.3.310.0070.00016.50
7.3.300.0070.00016.43
7.3.290.0030.01116.47
7.3.280.0030.01316.46
7.3.270.0080.00817.40
7.3.260.0110.01116.66
7.3.250.0040.01316.54
7.3.240.0090.01616.57
7.3.230.0120.00616.47
7.3.210.0080.00916.48
7.3.200.0070.01019.39
7.3.190.0060.01516.45
7.3.180.0110.00516.72
7.3.170.0000.01616.41
7.3.160.0040.01216.46
7.3.120.0040.01117.15
7.3.110.0090.00617.15
7.3.100.0080.00817.15
7.3.90.0000.01717.15
7.3.80.0070.00717.15
7.3.70.0030.01017.15
7.3.60.0080.00417.15
7.3.50.0090.00617.15
7.3.40.0030.01017.15
7.3.30.0000.01617.15
7.3.20.0060.00917.15
7.3.10.0110.00616.79
7.3.00.0100.00716.77
7.2.330.0090.00916.75
7.2.320.0120.00616.55
7.2.310.0120.00916.85
7.2.300.0000.01816.52
7.2.290.0070.01016.82
7.2.240.0100.00317.15
7.2.230.0040.01417.15
7.2.220.0090.00317.15
7.2.210.0090.00917.15
7.2.200.0070.01017.15
7.2.190.0100.00617.15
7.2.180.0070.01017.15
7.2.170.0060.01017.15
7.2.160.0060.01017.15
7.2.150.0000.01717.15
7.2.140.0070.01017.15
7.2.130.0130.00916.99
7.2.120.0080.00617.01
7.2.110.0080.00816.99
7.2.100.0060.00917.00
7.2.90.0030.01016.86
7.2.80.0050.00916.90
7.2.70.0080.00616.88
7.2.60.0100.00716.89
7.2.50.0030.01216.82
7.2.40.0070.00716.99
7.2.30.0070.00716.92
7.2.20.0070.00816.95
7.2.10.0080.00816.88
7.2.00.0050.00617.84
7.1.330.0080.00817.15
7.1.320.0030.01017.15
7.1.310.0030.01217.15
7.1.300.0080.00617.15
7.1.290.0030.01317.15
7.1.280.0040.01117.15
7.1.270.0030.00917.15
7.1.260.0040.00817.15
7.1.250.0150.00216.31
7.1.200.0070.00015.82
7.1.70.0000.01017.28
7.1.60.0030.00917.24
7.1.50.0260.01034.80
7.1.00.0030.04722.57
7.0.200.0000.01016.75
7.0.140.0070.06721.90
7.0.60.0070.04319.90
7.0.50.0030.09017.85
7.0.40.0000.08320.30
7.0.30.0330.03720.21
7.0.20.0200.05320.07
7.0.10.0070.05020.19
7.0.00.0100.08320.24
5.6.280.0170.06321.16
5.6.210.0030.04320.55
5.6.200.0130.08318.17
5.6.190.0100.08020.34
5.6.180.0430.08320.33
5.6.170.0230.05720.60
5.6.160.0130.08320.50
5.6.150.0030.09018.19
5.6.140.0070.04018.16
5.6.130.0100.07018.13
5.6.120.0030.08321.05
5.6.110.0030.04021.01
5.6.100.0030.05321.02
5.6.90.0000.08021.03
5.6.80.0030.09020.43
5.5.350.0270.07720.47
5.5.340.0030.08317.95
5.5.330.0070.08320.37
5.5.320.0200.04720.27
5.5.310.0330.07720.41
5.5.300.0100.07318.06
5.5.290.0100.07317.98
5.5.280.0130.03721.01
5.5.270.0030.08720.79
5.5.260.0130.08020.82
5.5.250.0070.08320.62
5.5.240.0030.03720.30
5.4.450.0700.06719.45
5.4.440.0570.06319.32
5.4.430.0100.05319.39
5.4.420.0030.06019.51
5.4.410.0070.05319.06
5.4.400.0170.04718.88
5.4.390.0100.05718.56
5.4.380.0070.05718.77
5.4.370.0330.05318.62
5.4.360.0170.05718.83
5.4.350.0040.03812.05
5.4.340.0080.04112.05
5.4.320.0070.03912.53
5.4.310.0070.04712.53
5.4.300.0070.04012.53
5.4.290.0080.04312.53
5.4.280.0050.04712.43
5.4.270.0080.03412.43
5.4.260.0060.03712.43
5.4.250.0170.04718.95
5.4.240.0070.05718.79
5.4.230.0100.05318.80
5.4.220.0200.07018.75
5.4.210.0030.05718.94
5.4.200.0130.04718.97
5.4.190.0070.05718.94
5.4.180.0170.04718.80
5.4.170.0030.05718.99
5.4.160.0070.05318.93
5.4.150.0100.05019.08
5.4.140.0170.04716.45
5.4.130.0030.05016.50
5.4.120.0030.06716.60
5.4.110.0170.04016.71
5.4.100.0100.04716.63
5.4.90.0030.05016.45
5.4.80.0100.04316.61
5.4.70.0170.06016.55
5.4.60.0100.04716.46
5.4.50.0200.03716.50
5.4.40.0100.04716.52
5.4.30.0000.05316.54
5.4.20.0100.04316.61
5.4.10.0170.04316.54
5.4.00.0000.05315.86
5.3.290.0120.04812.80
5.3.280.0070.05014.86
5.3.270.0070.05314.74
5.3.260.0070.05314.74
5.3.250.0070.05014.64
5.3.240.0030.05714.63
5.3.230.0100.04714.63
5.3.220.0030.05714.68
5.3.210.0070.07314.52
5.3.200.0100.04314.61
5.3.190.0100.05014.58
5.3.180.0170.04314.70
5.3.170.0000.05714.61
5.3.160.0030.06014.46
5.3.150.0100.05014.68
5.3.140.0130.04314.77
5.3.130.0030.05714.66
5.3.120.0170.05014.69
5.3.110.0130.04314.66
5.3.100.0000.05714.16
5.3.90.0070.05314.14
5.3.80.0000.05714.15
5.3.70.0070.06714.05
5.3.60.0170.04314.13
5.3.50.0100.04714.21
5.3.40.0000.05314.07
5.3.30.0130.04314.04
5.3.20.0000.05313.92
5.3.10.0170.03713.85
5.3.00.0100.04713.66
5.2.170.0030.04311.38
5.2.160.0030.04311.14
5.2.150.0030.04711.28
5.2.140.0100.03711.27
5.2.130.0030.04311.22
5.2.120.0030.04011.11
5.2.110.0070.03711.22
5.2.100.0070.03711.12
5.2.90.0000.04311.22
5.2.80.0100.03711.14
5.2.70.0030.04011.24
5.2.60.0100.03711.18
5.2.50.0030.04011.05
5.2.40.0030.04011.27
5.2.30.0030.04311.02
5.2.20.0070.04011.07
5.2.10.0030.04010.88
5.2.00.0130.03310.60
5.1.60.0100.03010.02
5.1.50.0030.0479.88
5.1.40.0070.0479.95
5.1.30.0000.04310.36
5.1.20.0030.03710.39
5.1.10.0030.03710.20
5.1.00.0000.04310.21
5.0.50.0000.0378.68
5.0.40.0030.0278.44
5.0.30.0000.0478.43
5.0.20.0000.0308.22
5.0.10.0070.0238.02
5.0.00.0000.0478.28
4.4.90.0030.0207.42
4.4.80.0000.0237.42
4.4.70.0030.0207.42
4.4.60.0030.0207.42
4.4.50.0000.0237.42
4.4.40.0030.0337.42
4.4.30.0000.0237.42
4.4.20.0070.0207.42
4.4.10.0030.0207.42
4.4.00.0070.0337.42
4.3.110.0070.0177.42
4.3.100.0070.0177.42
4.3.90.0030.0177.42
4.3.80.0000.0337.42
4.3.70.0000.0207.42
4.3.60.0030.0207.42
4.3.50.0000.0237.42
4.3.40.0000.0407.42
4.3.30.0070.0177.42
4.3.20.0070.0207.42
4.3.10.0030.0207.42
4.3.00.0000.0236.52

preferences:
51.12 ms | 401 KiB | 5 Q