Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Render time of my page

Tags:

php

rendering

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

like image 519
AvinD Avatar asked Aug 11 '11 10:08

AvinD


2 Answers

Update on original approved answer (for future people 'Googling' and cut-n-paste mojo):

For PHP 5.X+, you not only have to add 'true' as a parameter to both microtime() vars, but we don't have to divide it by 1,000 anymore. So the 2013 answer is:

Start of script:

$start = microtime(true);

Bottom of script:

$end = microtime(true);
$creationtime = ($end - $start);
printf("Page created in %.6f seconds.", $creationtime);
like image 160
Ryan Robitaille Avatar answered Sep 29 '22 00:09

Ryan Robitaille


If you're looking to figure out how long it took your server to create the page (for example, to display this to the user), then you'll want to put this at the start of the code:

$start = microtime();

And then at the end put this:

$end = microtime();
$creationtime = ($end - $start) / 1000;
printf("Page created in %.5f seconds.", $creationtime);
like image 37
EdoDodo Avatar answered Sep 29 '22 02:09

EdoDodo