Jump to content

Recommended Posts

Hi,

 

just a quick one im running PHP 5.2 on IIS 6 (Windows 2003 Server) and im getting a weird load time result when trying to display page load times on each page.

 

e.g.

Page generated in 1193387528.5501 seconds.

 

this is my current code

<?php
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 4);
echo '<p>Page generated in '.$total_time.' seconds.</p>'."\n";
?>

 

but i've tried 4 others which are all simular. Any idea as to why it's showing a false result as it's loading in unde 1 second (Dual Xeon 2.8 HT server and connecting over 100mb pipe (college campus))

 

 

Regards

Liam

You havent got the second microtime.

 

Try this.

$time = microtime();

$time = explode(" ", $time);

$time = $time[1] + $time[0];

$start = $time;

 

content your testing

 

$time = microtime();

$time = explode(" ", $time);

$time = $time[1] + $time[0];

$finish = $time;

$totaltime = ($finish - $start);

printf ("Page took %f seconds to load.", $totaltime);

Try this.

$time = microtime();

$time = explode(" ", $time);

$time = $time[1] + $time[0];

$start = $time;

 

content your testing

 

$time = microtime();

$time = explode(" ", $time);

$time = $time[1] + $time[0];

$finish = $time;

$totaltime = ($finish - $start);

printf ("Page took %f seconds to load.", $totaltime);

 

 

worked great.. i realised as i went down the page of a site i copied the bottom code but not the top..

 

My fault :)

 

Thanks alot :)

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.