Reputation: 3188
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.
Upvotes: 0
Views: 107
Reputation: 62924
Quick and dirty:
$q = "SELECT foo FROM BAR";
$start = microtime(true);
$res = query($q);
$end = microtime(true);
echo "Query took " . ( $end-$start) . " seconds";
Upvotes: 4