Solved

how can i know what is the time that it takes the script to run and finsh ?

Posted on 2008-09-29
4
200 Views
Last Modified: 2008-09-29
how can i know what is the time that it takes the script to run and finsh ?
0
Comment
Question by:mgtm3
4 Comments
 
LVL 8

Accepted Solution

by:
MatthiasVance earned 300 total points
ID: 22597585
You can use the gettimeofday() function on the beginning and the end of your script, like this.

Kind regards,

Matthias Vance
<?php

	$start = gettimeofday(true);

	// Your code here.

	$end = gettimeofday(true);

	$duration = $end - $start;

	echo "Duration: " . $duration;

?>

Open in new window

0
 
LVL 82

Assisted Solution

by:hielo
hielo earned 75 total points
ID: 22597658
0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 75 total points
ID: 22597993
I use this...
<?php

// SCRIPT TIMER AT START OF SCRIPT

list ($x, $y) = explode(" ", microtime()); $script_start_time = $x + $y;
 

/* EXECUTE SCRIPT HERE */
 

// AT END OF SCRIPT

list ($x, $y)		= explode(" ", microtime());

$script_stop_time	= $x + $y;

$script_duration	= number_format( ($script_stop_time - $script_start_time) ,3);

echo "$script_duration Seconds";

?>

Open in new window

0
 
LVL 9

Assisted Solution

by:khaledf
khaledf earned 50 total points
ID: 22598116
I use this code:
put your page code between these 2 php blocks
<?  $time = microtime(true);  ?>  
 
 
 

<?   

$time2 = microtime(true);   

$gentime = $time2 - $time;

echo "$gentime";

?>

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
php call to a non-object 3 32
mcrypt_create_iv() is deprecated 4 69
Calculating number of days between two dates 7 31
Session timeout 5 13
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
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 …

911 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

15 Experts available now in Live!

Get 1:1 Help Now