Solved

php file execution time

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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

832 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