Skip to content

Commit

Permalink
Use float seconds for timestamps and stopwatch as per how the connect…
Browse files Browse the repository at this point in the history
…ion settings are configured
  • Loading branch information
karpilin authored and prolic committed Oct 9, 2024
1 parent 0950b83 commit 0218175
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Internal/StopWatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,20 @@
/** @internal */
class StopWatch
{
private function __construct(private readonly int $started)
private function __construct(private readonly float $started)
{
}

public static function startNew(): self
{
$now = DateTime::utcNow();
$started = (int) \floor((float) $now->format('U.u') * 1000);
$started = microtime(true);

return new self($started);
}

public function elapsed(): int
public function elapsed(): float
{
$now = DateTime::utcNow();
$timestamp = (int) \floor((float) $now->format('U.u') * 1000);
$timestamp = microtime(true);;

return $timestamp - $this->started;
}
Expand Down

0 comments on commit 0218175

Please sign in to comment.