Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9d7d4dc

Browse files
AmirRezaM75GromNaN
andauthored
PHPORM-330 Fix: Convert query duration time to milliseconds (#3374)
* Convert query duration time to milliseconds * Test that query time is expressed in milliseconds --------- Co-authored-by: Jérôme Tamarelle <jerome.tamarelle@mongodb.com>
1 parent 397a3e3 commit 9d7d4dc

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

‎src/CommandSubscriber.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ private function logQuery(CommandSucceededEvent|CommandFailedEvent $event): void
4848
}
4949
}
5050

51-
$this->connection->logQuery(Document::fromPHP($command)->toCanonicalExtendedJSON(), [], $event->getDurationMicros());
51+
$this->connection->logQuery(Document::fromPHP($command)->toCanonicalExtendedJSON(), [], $event->getDurationMicros() / 1000);
5252
}
5353
}

‎tests/ConnectionTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ public function testQueryLog()
289289
DB::table('items')->get();
290290
$this->assertCount(1, $logs = DB::getQueryLog());
291291
$this->assertJsonStringEqualsJsonString('{"find":"items","filter":{}}', $logs[0]['query']);
292+
$this->assertLessThan(10, $logs[0]['time'], 'Query time is in milliseconds');
293+
$this->assertGreaterThan(0.01, $logs[0]['time'], 'Query time is in milliseconds');
292294

293295
DB::table('items')->insert(['id' => $id = new ObjectId(), 'name' => 'test']);
294296
$this->assertCount(2, $logs = DB::getQueryLog());

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /