3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface ClockInterface { public function now(): DateTimeImmutable; } class BadMockClock implements ClockInterface { public function __construct(private readonly DateTimeImmutable $now = new DateTimeImmutable()) { } public function now(): DateTimeImmutable { return $this->now; } } class GoodMockClock implements ClockInterface { public function __construct(private readonly DateTimeImmutable $now = new DateTimeImmutable()) { } public function now(): DateTimeImmutable { return clone $this->now; } } class Clock implements ClockInterface { public function now(): DateTimeImmutable { return new DateTimeImmutable(); } } $clocks = [ new BadMockClock(), new GoodMockClock(), new Clock(), ]; shuffle($clocks); foreach ($clocks as $i => $clock) { $t1 = $clock->now(); $t2 = $clock->now(); if ($t1 === $t2) { echo "Clock mock leaks at index $i\n"; } }

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.2.50.0060.00619.53

preferences:
26.68 ms | 403 KiB | 5 Q