If its the SQL query you're strictly interested in, you might look into doing a SQL "explain" on the select query you're playing with. Typically this is best done from a query tool such as SQL Enterprise Manager (for MS SQL) or phpMyAdmin (MySQL) or something similar (although its not impossible to do it from PHP, but you'd have to write code to display the explain results).
If you're just interested in timing your code, including the query time, you'll want to check out [man]microtime[/man]. In the comments is this (very handy code here):
gordon at kanazawa-gu dot ac dot jp
28-Dec-2002 06:29
shorter version of function to get difference between two microtimes:
function microtime_diff($a, $b) {
list($a_dec, $a_sec) = explode(" ", $a);
list($b_dec, $b_sec) = explode(" ", $b);
return $b_sec - $a_sec + $b_dec - $a_dec;
}
Use as follows:
$start_time = microtime();
/
... do your processing here ...
/
$duration = microtime_diff($start_time, microtime());
$duration = sprintf("%0.3f", $duration);
echo ("Processing took $duration seconds");