lucasl Posted December 17, 2006 Share Posted December 17, 2006 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]. Quote Link to comment Share on other sites More sharing options...
trq Posted December 17, 2006 Share Posted December 17, 2006 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. Quote Link to comment Share on other sites More sharing options...
lucasl Posted December 17, 2006 Author Share Posted December 17, 2006 That didn't work, and I didn't think it would. The computer doesn't care what order I add things in, or what my variables are called.PS. Thanks for the <?php tip. Quote Link to comment Share on other sites More sharing options...
trq Posted December 17, 2006 Share Posted December 17, 2006 Sorry, I'll admit I didn't really look to closely at your script. Mine however is working fine here and produces....[code]Page loaded in 0.00172 secs.[/code]What do you get? Quote Link to comment Share on other sites More sharing options...
lucasl Posted December 17, 2006 Author Share Posted December 17, 2006 I got 0 if I rounded it to 4 or less, and 3E-05 for 5. I haven't tried 6. Quote Link to comment Share on other sites More sharing options...
trq Posted December 17, 2006 Share Posted December 17, 2006 Just a thought but here is a setting in the php.ini that [i]may[/i] have something to do with this. The [i]precision[/i] directive. Mine is set to 12, whats yours? Quote Link to comment Share on other sites More sharing options...
lucasl Posted December 17, 2006 Author Share Posted December 17, 2006 Mine is as wellPS.I can't post for 20-50 mins Quote Link to comment Share on other sites More sharing options...
trq Posted December 17, 2006 Share Posted December 17, 2006 Well, Im sorry but Ive no idea. Its working fine here. Quote Link to comment Share on other sites More sharing options...
lucasl Posted December 17, 2006 Author Share Posted December 17, 2006 Anyone Else know? Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted December 17, 2006 Share Posted December 17, 2006 nope i tryed the mentioned way and it worked for me here check it out http://dreamshowstudios.net its at bottom Quote Link to comment Share on other sites More sharing options...
lucasl Posted December 17, 2006 Author Share Posted December 17, 2006 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 commandEDIT: And by millisecs I mean microtime():) Quote Link to comment Share on other sites More sharing options...
lucasl Posted December 17, 2006 Author Share Posted December 17, 2006 I used number_format, and it worked fine. Or did it? It keeps saying it loaded in 0.00005 or less seconds!Can somebody test it [url=http://www.freesoft.logical-host.com/]here[/url] (its at the bottom of the page)? Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted December 17, 2006 Share Posted December 17, 2006 Page loaded in 0.00005 secsthats wat it said Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.