Anywhere in any PHP script where you want to measure how long it took to do something. It's just a brute force way to get some raw performance data (as opposed to installing monitoring/measurement tools that might give more overall coverage with nice reporting tools, but at a monetary price 😉 ). To give my example a little more context:
<?php
class Foo {
public function bar() {
$start = microtime(true);
$sql = "some amazing DB query goes here";
$stmt = $this->pdo->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
error_log("Foo::bar() took " . microtime(true) - $start . " seconds.");
return $result;
}
}
Then you can inspect your PHP error log to see what it says. phpinfo()
can tell you where things are logged by default, or you can add the necessary parameters to error_log()
as to where you want it to write the message.