...

View Full Version : Execution Time



Tony M
08-20-2011, 12:51 AM
I have searched all over the net about: calculating php execution time (of all My page) and found many many and many ways to do it...

But what is the best correct and accurate way? (to calculate php (total) execution time of a page)

Nightfire
08-20-2011, 01:01 AM
Easiest and works just the same as every other way


<?php

$start = microtime(true);
/*
source code here
*/
$end = microtime(true);

echo "Page took " .($end - $start). " seconds to execute";

?>

Tony M
08-20-2011, 01:14 AM
Easiest and works just the same as every other way


<?php

$start = microtime(true);
/*
source code here
*/
$end = microtime(true);

echo "Page took " .($end - $start). " seconds to execute";

?>

Thanks. But I am now really confused between whether to use the code above or the code at http://www.developerfusion.com/code/2058/determine-execution-time-in-php/ (someone told Me it's the most accurate...)

Is there is any difference between the two? :confused:

Nightfire
08-20-2011, 01:26 AM
Don't know tbh, to me it looks like they do exactly the same thing. They're both using microtime which is showing by microseconds (0.000000000000001 seconds)

kbluhm
08-20-2011, 01:59 AM
Yeah, the two are identical... except I would guess using microtime( TRUE ) is faster than using microtime() and converting the string value to a float, as microtime( TRUE ) already returns a float... so no parsing is necessary.

Fou-Lu
08-20-2011, 05:48 AM
microtime(true) is a newer feature as of 5.0. Prior to this, you had to split off the msec and sec from the string by exploding it. If you're on a newer system, microtime(true) is a lot easier to do and theoretically faster than just a microtime().

In other words, the link you have is to old code, which btw is perfectly good code to use even as of today.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum