?
Solved

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

Posted on 2008-09-29
4
Medium Priority
?
206 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
[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
4 Comments
 
LVL 8

Accepted Solution

by:
MatthiasVance earned 1200 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 300 total points
ID: 22597658
0
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 300 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 200 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

WordPress Tutorial 2: Terminology

An important part of learning any new piece of software is understanding the terminology it uses. Thankfully WordPress uses fairly simple names for everything that make it easy to start using the software.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
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…
Suggested Courses

801 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