Use the time() function to get the time at the start of the script and at the end. Subtract the start time from the end time to get the elapsed time (i.e. the amount of time the script took to run.)
Example:
<?php
$start_time=time();
/ rest of your script here /
$end_time=time();
$elapsed_time=$end_time-$start_time;
?>
I know this looks like a hack, but I worked for a major search engine company, and we used this to get the elapsed time for search results.