Solved

php file execution time

Posted on 2002-05-22
3
213 Views
Last Modified: 2006-11-17
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
0
Comment
Question by:tripat
  • 2
3 Comments
 
LVL 32

Expert Comment

by:Batalf
Comment Utility
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;



0
 
LVL 1

Author Comment

by:tripat
Comment Utility
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
0
 
LVL 32

Accepted Solution

by:
Batalf earned 200 total points
Comment Utility
I'm not used to asp, but I found a snippet at

http://www.4guysfromrolla.com/webtech/122799-1.shtml


Dim Iterations, StartTime, ElapsedTime, AverageTimePerIteration, X

Iterations = 1000
StartTime = Timer

For X = 1 TO Iterations
   '... do operations to be timed
Next

ElapsedTime = Timer - StartTime
AverageTimePerIteration = ElapsedTime / Iterations

0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now