My page time

Is there a way to get a php script that measures the localhost page rendering time. I looked around but didn’t find anything, maybe because I don’t know how to look for this kind of script.

+4
source share
3 answers

Update of the initial approved answer (for future people “Googling” and mo-mo-cut-n-paste):

For PHP 5.X + you need to not only add the “truth” as a parameter for the microtime () microarchive, but we no longer need to divide it by 1000. Therefore, the answer for 2013:

The beginning of the script:

$start = microtime(true); 

Bottom of the script:

 $end = microtime(true); $creationtime = ($end - $start); printf("Page created in %.6f seconds.", $creationtime); 
+18
source

If you want to find out how long it took your server to create the page (for example, to display this for the user), you will want to set this at the beginning of the code:

 $start = microtime(); 

And then put this at the end:

 $end = microtime(); $creationtime = ($end - $start) / 1000; printf("Page created in %.5f seconds.", $creationtime); 
+6
source

You cannot measure browser rendering time using PHP. All you can do is determine the time it takes the server to create the page.

However, if using javascript is ok, you can do the following:

 <html> <head> <script type="text/javascript"> var start_time=+new Date(); window.onload=function(){ alert("Page render time: " + ((+new Date()-start_time)/1000)); }; </script> </head> <body> <p>hi</p> </body> </html> 

If you want to use the browser plugin, look here: measure page rendering time in IE 6 or FF 3.x

+1
source

All Articles