shocker-z Posted October 26, 2007 Share Posted October 26, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/74850-solved-page-load-time-show-really-high-but-not/ Share on other sites More sharing options...
MemphiS Posted October 26, 2007 Share Posted October 26, 2007 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); Quote Link to comment https://forums.phpfreaks.com/topic/74850-solved-page-load-time-show-really-high-but-not/#findComment-378447 Share on other sites More sharing options...
ifm1989 Posted October 26, 2007 Share Posted October 26, 2007 try: <?php $start= microtime(); //PAGE CONTENT GOES HERE $finish = microtime(); echo '<p>Page generated in '.number_format(round($finish-$start,-4)).' seconds.</p>\n'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/74850-solved-page-load-time-show-really-high-but-not/#findComment-378448 Share on other sites More sharing options...
shocker-z Posted October 26, 2007 Author Share Posted October 26, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/74850-solved-page-load-time-show-really-high-but-not/#findComment-378499 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.