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).
Version | System time (s) | User time (s) | Memory (MiB) |
---|---|---|---|
8.2.5 | 0.006 | 0.006 | 19.53 |
<?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).
Version | System time (s) | User time (s) | Memory (MiB) |
---|---|---|---|
8.2.5 | 0.006 | 0.006 | 19.53 |