3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Entity { public function getId() : int; } class Comment implements Entity { private int $id; private int $userId; private string $text; public function __construct(int $id, int $userId, string $text) { $this->id = $id; $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): void { $this->text = $text; } } class CommentRepository { private array $entities = []; public function create(int $userId, string $text): Comment { $id = $this->generateId(); $entities[$id] = new Comment($id, $userId, $text); 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(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.0040.01216.41
7.4.00.0140.00916.54
7.3.130.0040.01116.19
7.3.120.0110.00716.29
7.3.110.0100.00616.18
7.3.100.0070.00716.25
7.3.90.0090.00616.13
7.3.80.0100.01016.31
7.3.70.0140.00616.10
7.3.60.0060.01116.20
7.3.50.0140.00716.12
7.3.40.0130.00316.13
7.3.30.0090.00616.07
7.3.20.0080.00816.29
7.3.10.0100.01316.15
7.3.00.0150.00316.14
7.2.260.0100.01016.23
7.2.250.0030.01316.41
7.2.240.0090.00616.29
7.2.230.0110.00616.14
7.2.220.0130.00316.41
7.2.210.0170.00416.36
7.2.200.0140.00416.33
7.2.190.0110.00616.29
7.2.180.0090.00916.57
7.2.170.0090.00616.29
7.2.160.0030.01316.29
7.2.150.0050.01316.52
7.2.140.0040.01216.22
7.2.130.0090.00616.39
7.2.120.0120.00616.41
7.2.110.0120.00616.38
7.2.100.0060.00916.26
7.2.90.0040.01216.16
7.2.80.0070.01016.38
7.2.70.0070.01116.25
7.2.60.0060.01016.27
7.2.50.0090.01216.39
7.2.40.0030.01316.48
7.2.30.0090.00916.47
7.2.20.0060.00916.38
7.2.10.0100.00716.34
7.2.00.0070.01016.52

preferences:
36.96 ms | 400 KiB | 5 Q