Poku
Poku

Reputation: 3188

PHP: How do i test the time which it takes to do a query?

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

Answers (1)

timdev
timdev

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

Related Questions