Solved

php file execution time

Posted on 2002-05-22
3
238 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
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 200 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

820 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