1

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!?

1 Answer 1

2

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.

1
  • 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. Oct 28, 2011 at 21:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .