Jump to content

php page load time


blakesmoore

Recommended Posts

Thanks for this Dan,

 

will this tell me how long it takes to load any site that i replace 'http://www.yourURL.com/page.html' with?

 

Yes, it should do.

 

You could even add a function you could use with a form rather than editing the PHP file all the time.

<?PHP
function websitetime($website)
{
$start = microtime(true);
file_get_contents($website);
echo "Page loaded in: ". number_format(microtime(true)-$start,2) . " seconds.<br />";
}

if(isset($_POST['submit']) && $_POST['website'])
{
$website = $_POST['website'];
websitetime($website);
}
?>

<form method="post">
Website: <input type="text" name="website" /> <br />
<input type="submit" value="Submit" name="submit" />
</form>

 

Should work, I haven't tested it though.

Link to comment
Share on other sites

the pingdom test also fetches external javascript and images.  If you want to find the complete load time of a site and all its assets, it will be a significantly longer script.  Many sites these days also draw a portion of their interface in javascript, which is even more difficult to time properly.

Link to comment
Share on other sites

The 3 line thing I gave you checks exactly what was asked for: The "load time" of an external script.  It measures the amount of time it takes for the script to execute and finish giving output.

 

The pingdom test does that, and then parses the output to see if it's HTML.  If it is, it fetches images, javascript, and CSS as well, probably in parallel. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.