3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CommentBase { private int $userId; private string $text; public function __construct(int $userId, string $text) { $this->userId = $userId; $this->text = $text; } public function getId() : int { return $this->id; } public function getUserId() : int { return $this->userId; } public function getText() : string { return $this->text; } public function setText(string $text) { $this->text = $text; } } interface Entity { public function getId() : int; } class Comment extends CommentBase implements Entity { private int $id; public function __construct(int $id, int $userId, string $text) { $this->id = $id; parent::__construct($userId, $text); } public function getId() : int { return $this->id; } } class CommentRepository { private array $entities = []; public function create(CommentBase $comment): Comment { $id = $this->generateId(); $entities[$id] = new Comment($id, $comment->getUserId(), $comment->getText()); return $entities[$id]; } public function update(Comment $comment): Comment { $this->entities[$comment->getId()] = $comment; return $this->entities[$comment->getId()]; } private function generateId() : int { return random_int(1, 1000000); } } $repo = new CommentRepository; $comment = $repo->create(new CommentBase(11, 'Test comment')); $comment->setText("updated comment"); $comment = $repo->update($comment); var_dump($comment);

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)
7.4.10.0070.01016.41
7.4.00.0060.01016.43
7.3.130.0120.00316.42
7.3.120.0090.01316.21
7.3.110.0110.00416.06
7.3.100.0120.00316.31
7.3.90.0140.00316.22
7.3.80.0110.00716.16
7.3.70.0080.00616.14
7.3.60.0030.01216.14
7.3.50.0090.00615.99
7.3.40.0070.00716.11
7.3.30.0050.01316.14
7.3.20.0080.00816.06
7.3.10.0040.01516.13
7.3.00.0090.01116.28
7.2.260.0030.01316.45
7.2.250.0120.00316.21
7.2.240.0030.01316.39
7.2.230.0060.00916.54
7.2.220.0080.01116.25
7.2.210.0000.01516.23
7.2.200.0030.01216.38
7.2.190.0100.00616.39
7.2.180.0090.00616.36
7.2.170.0060.01316.04
7.2.160.0070.01116.20
7.2.150.0110.00916.36
7.2.140.0100.01016.37
7.2.130.0100.00616.37
7.2.120.0110.00716.53
7.2.110.0060.01016.48
7.2.100.0030.01316.19
7.2.90.0170.00016.47
7.2.80.0060.01416.39
7.2.70.0110.00716.20
7.2.60.0130.00316.16
7.2.50.0060.01016.36
7.2.40.0100.00716.38
7.2.30.0110.00716.38
7.2.20.0060.01316.37
7.2.10.0120.00316.34
7.2.00.0120.00616.27

preferences:
34.46 ms | 401 KiB | 5 Q