
Originally Posted by
shortcircuit
... why would you look at it in Firebug instead of Firefox and other browsers instead?
With 20 years+ as a professional webmaster no doubt you would have heard of the Firefox extension "Firebug"? :P It's the leading website diagnostic tools for developers and has been so for 3-5 years.
A very simple technique is to sprinkle some echo lines through your code, displaying the elapsed execution time.
You can use PHP's microtime call() to gauge this with a little more accuracy.
If you want to get more serious, there are libraries that assist with execution profiling, so that may be an alternative - but in your case, probably overkill at the moment.
I've enclosed a first stab at a simple function that you can call throughout your code to show elapsed time between various parts - should make it very easy to see where most time is being used. Apologies in advance for any syntax or other errors - but it should be enough for you to get the idea!
Although, I have to say, 1 second or so isn't that slow!
I'd also check ping time to the web host - that may be a part of the delay.
PHP Code:
function log_time_elapsed($msg = '')
{
static $microtime_start = null;
list($u, $s) = explode(' ', microtime());
if($microtime_start === null)
{
$microtime_start = $u;
return 0;
}
list($u, $s) = explode(' ', microtime());
$diff = $u - $microtime_start;
$microtime_start = $u;
if (! empty($msg))
echo "$msg: elapsed microsecs $diff <br>\n";
return $diff;
}
// example use:
log_time_elapsed(); // first call initializes
...
log_time_elapsed("before db access");
// do db access ...
// ...
log_time_elapsed("after db access");
Bookmarks