[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

php file execution time

Posted on 2002-05-22
3
Medium Priority
?
265 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 32

Expert Comment

by:Batalf
ID: 7026582
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
ID: 7027744
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 800 total points
ID: 7027759
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

656 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