PHP:我如何测试查询所需的时间?

How do i test the speed of a database call from PHP?

I interested in testing how many miliseconds it takes my script to call the database with a query and gets the result. For example how many milisecond would the query below take to execute:

SELECT * FROM customers OrderBy customer_id

Thanks in advance.

Quick and dirty:

$q = "SELECT foo FROM BAR";
$start = microtime(true);
$res = query($q);
$end = microtime(true);

echo "Query took " . ( $end-$start) . " seconds";