I'd like to get time (ms) from php request to response for each hit on a page.

Can this be done through lighttpd, or should it be done in php? How?

If done in php, what would be the best performing way of keeping the data so that storing the data does not cost 1/2 of the duration!?

link|improve this question
feedback

1 Answer

Place this code in first line after open tag PHP:

$time = explode(' ', microtime());
$time = $time[1] + $time[0];
$begintime = $time;

And place this code before closing tag PHP:

$time = explode(" ", microtime());
$time = $time[1] + $time[0];
$endtime = $time;
$totaltime = ($endtime - $begintime);
echo $totaltime.' seconds';

You can store the result in Mysql with 'INSERT DELAYED' for maximum performance.

link|improve this answer
I like it. Never knew about the "DELAYED" option! That'll actually save a lot of time in the page that I was wanting to time!! I'll mark it true in another hour. Just want to see if there are any other ideas floating out there. – divitiae Oct 28 '11 at 21:52
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.