Skip to content

Commit

Permalink
Fix elapsedMicros always returning zero (#98)
Browse files Browse the repository at this point in the history
* Fix elapsedMicros always returning zero

`$this->start` and `$this->end` have the same unit, inferred via `endTime()`.
That function adds the two without doing a unit conversion first.
`$this->start` has the unit seconds.

`elapsedMicros()` used to divide by 1_000_000 and return megaseconds.
By swapping the division with a multiplication, `elapsedMicros()` now returns microseconds.

* Remove underscores from numeric literal
  • Loading branch information
lexidor authored May 4, 2023
1 parent b706db5 commit 395f442
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/AsyncMysql/AsyncMysqlConnectResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(bool $from_pool) {

<<__Override>>
public function elapsedMicros(): int {
return (int)($this->elapsed / 1000000);
return (int)($this->elapsed * 1000000);
}
<<__Override>>
public function startTime(): float {
Expand Down

0 comments on commit 395f442

Please sign in to comment.