Jump to content

Page loading in 0 or 3E-05 seconds?


lucasl

Recommended Posts

Hi,
I'm doing a page load time on my website, but for some reason its not working. When I round the final time result to 4 or less, it just displays zero. When its five, it shows '3E-05'. Also, echo 'Page loaded in $fintime secs.' doesn't display the variable, it just displays $fintime. Here's my code.
[code]
//At the top:
<?
  $mtime = explode(' ', microtime());
  $starttime = $mtime[0] + $mtime[1];
?>
//At the bottom:
  <?
    $mtime = explode(' ', microtime());
    $fintime = $mtime[0] + $mtime[1];
    $loadtime = $fintime - $starttime;
    $loadtime = round($loadtime, 5);
    echo 'Page loaded in '.$loadtime.' secs.';
  ?>
[/code]
If you want to see my html as well, view the page source source [url=http://www.freesoft.logical-host.com]here[/url].
Link to comment
Share on other sites

Your script is all a bit backward. Try...

[code]
<?php
  // top
  $time = explode(' ', microtime());
  $start = $time[1] + $time[0];
?>

<?php
  // bottom
  $time = explode(' ', microtime());
  $finish = $time[1] + $time[0];
  $total_time = round(($finish - $start), 5);
  echo "Page loaded in $total_time secs.";
?>
[/code]

PS and OT but, also note that using the full <?php tags enables syntax highlighting on the board. Its a good idea to get into that habbit of coding with it anyway as its guarenteed to work on all servers.
Link to comment
Share on other sites

Here's an interesting note, look at this:
[code]Starttime Raw: 0.43816100, 1166334795 Fintime Raw: 0.43820800, 1166334795Page loaded in 5E-05 secs. fin: 1166334795.44 start: 1166334795.44[/code]
Thats all the variables. Raw is the array result of millisecs seperated by a comma. I think something is wrong with my millisecs command

EDIT: And by millisecs I mean microtime():)
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.