Skip to content

Commit

Permalink
Fix elapsedMicros always returning zero
Browse files Browse the repository at this point in the history
`$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.
  • Loading branch information
lexidor committed Apr 27, 2023
1 parent b706db5 commit 6a1ef35
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 * 1_000_000);
}
<<__Override>>
public function startTime(): float {
Expand Down

0 comments on commit 6a1ef35

Please sign in to comment.