From 395f442a57e48f3a7e65858a3b518a1ac013b4b6 Mon Sep 17 00:00:00 2001 From: Lexidor Digital <31805625+lexidor@users.noreply.github.com> Date: Thu, 4 May 2023 23:00:58 +0200 Subject: [PATCH] Fix elapsedMicros always returning zero (#98) * 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 --- src/AsyncMysql/AsyncMysqlConnectResult.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AsyncMysql/AsyncMysqlConnectResult.php b/src/AsyncMysql/AsyncMysqlConnectResult.php index 0dea1aa..fecd331 100644 --- a/src/AsyncMysql/AsyncMysqlConnectResult.php +++ b/src/AsyncMysql/AsyncMysqlConnectResult.php @@ -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 {