3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Collection implements IteratorAggregate { private $list = []; public function __construct(array $list = []) { $this->list = $list; } public function add(string $string): void { $this->list[] = $string; } public function getIterator(): Traversable { return new ArrayIterator($this->list); } public function map(callable $callback): self { return new static(array_map($callback, $this->list)); } public function each(callable $callback) { foreach ($this->list as $key => $item) { $this->list[$key] = $callback($item); } return $this; } } function generateArray(): array { return array_fill(0, 400000, 'test'); } $collection = new Collection(generateArray()); $collection->each(fn($value) => $value . 's'); var_dump($collection);

Abusive script

This script was stopped while abusing our resources

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.110.0380.03442.86
8.3.100.0160.02341.13
8.3.90.0350.03943.04
8.3.80.0170.02743.24
8.3.70.0560.02341.11
8.3.60.0370.04741.00
8.3.50.0470.03340.73
8.3.40.0340.03446.15
8.3.30.0360.03344.67
8.3.20.0480.02746.19
8.3.10.0230.01946.28
8.3.00.0170.01748.23
8.2.230.0280.02240.88
8.2.220.0330.02340.83
8.2.210.0220.03544.85
8.2.200.0230.03941.13
8.2.190.0590.03940.98
8.2.180.0390.04840.88
8.2.170.0330.03643.25
8.2.160.0300.04144.89
8.2.150.0260.03244.89
8.2.140.0250.01945.74
8.2.130.0180.03243.83
8.2.120.0030.02746.80
8.2.110.0140.04148.89
8.2.100.0390.05242.28
8.2.90.0210.02442.24
8.2.80.0140.03443.72
8.2.70.0280.02541.75
8.2.60.0160.04341.63
8.2.50.0350.02641.88
8.2.40.0320.02942.00
8.2.30.0390.02341.88
8.2.20.0290.02941.88
8.2.10.0300.02641.85
8.2.00.0070.05042.00
8.1.290.0250.02254.90
8.1.280.0550.03652.88
8.1.270.0190.00734.29
8.1.260.0090.00631.31
8.1.250.0130.00034.48
8.1.240.0170.01332.95
8.1.230.0160.00333.22
8.1.220.0100.00330.03
8.1.210.0030.01030.88
8.1.200.0130.00929.50
8.1.190.0140.00729.25
8.1.180.0180.00429.23
8.1.170.0210.00029.38
8.1.160.0080.01229.25
8.1.150.0160.00529.38
8.1.140.0150.00629.38
8.1.130.0150.00629.25
8.1.120.0210.00029.38
8.1.110.0180.00429.13
8.1.100.0190.00329.25
8.1.90.0110.01129.63
8.1.80.0090.01329.50
8.1.70.0150.00629.36
8.1.60.0120.01229.63
8.1.50.0200.00329.60
8.1.40.0190.00329.75
8.1.30.0160.00529.63
8.1.20.0200.00229.50
8.1.10.0320.03654.00
8.1.00.0190.04553.75
8.0.300.0130.03456.66
8.0.290.0210.03952.97
8.0.280.0180.04453.25
8.0.270.0380.02852.97
8.0.260.0320.03553.13
8.0.250.0190.04153.09
8.0.240.0200.04052.75
8.0.230.0190.04553.10
8.0.220.0370.02852.85
8.0.210.0350.02953.13
8.0.200.0320.03253.25
8.0.190.0340.02653.25
8.0.180.0230.03853.25
8.0.170.0320.02953.38
8.0.160.0240.03552.75
8.0.150.0350.03553.11
8.0.140.0260.03753.11
8.0.130.0340.03053.13
8.0.120.0270.03753.13
8.0.110.0380.02453.25
8.0.100.0260.03653.13
8.0.90.0310.03453.00
8.0.80.0360.03053.13
8.0.70.0290.03553.00
8.0.60.0340.03153.13
8.0.50.0280.03553.10
8.0.30.0280.03553.13
8.0.20.0360.02353.38
8.0.10.0370.02753.21

preferences:
23.82 ms | 403 KiB | 5 Q