Link to home
Start Free TrialLog in
Avatar of tripat
tripat

asked on

php file execution time

Dear Experts,

How can we calculate, the running/execution time of a php file?

I mean lets say I have 2 files, file1.php and file2.php doing the same function but in different logic, so how can i say that the file1.php is faster or file2.php is faster.

By loading them in browsers, It alot depends on present internet connection speed so we cannot rely on that. What are the other possible ways of checking this.

Regards,
Tripat
Avatar of Batalf
Batalf
Flag of United States of America image

At the start of the file:


function getmicrotime(){
    list($usec, $sec) = explode(" ",microtime());
    return ((float)$usec + (float)$sec);
    }

$time_start = getmicrotime();

.....

and at the end of the file

echo "execution time : ".getmicrotime() - $time_start;



Avatar of tripat
tripat

ASKER

thanks for your comments, it is quite useful.

can u also guide me how can I do same on asp file also, if I have to comapre an asp file with php file runing on same server using chillisoft.

regards,
tripat
ASKER CERTIFIED SOLUTION
Avatar of Batalf
Batalf
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial