Re: [PHP] Time consumed in microseconds

2004-08-31 Thread Karam Chand
Darn missed it. Looking into the docs I am using code
somthing like this:

$start   = microtime();
$result  = mysql_query ( $query, $mysql );
$end = microtime();

$diff   =  microtime_diff ($start, $end);

function microtimdiff() is given by:

function microtime_diff($a, $b)
{
   list($a_dec, $a_sec) = explode( , $a);
   list($b_dec, $b_sec) = explode( , $b);

   return ((float)$b_sec - (float)$a_sec +
(float)$b_dec - (float)$a_dec);
}

The result from one operation is like:

$start = 0.26562800 1093931165
$end = 0.26813400 1093931165
$diff = 0.002506

So to get the difference in ms I have to multilply
$diff by 1000. 

Am I correct?

Regards,
Karam

--- John Holmes [EMAIL PROTECTED] wrote:

 Karam Chand wrote:
  In Win32 API to profile a job we use the following
  method:
  
  
   timetaken = GetTickCount();
   /* do some job */
   timetaken = GetTickCount() - timetaken;
  
  In this way timetaken returns you the time taken
 by
  the job to complete?
  
  How can I get it in PHP. I want the exact figure
 in
  ms? I used microtime() and the samples given in
  php.net but none of them correctly returns the
  difference only in ms?
 
 Read the manual page again. Use the example to get
 the microtime as a 
 float at the start and then after your job. Subtract
 to get the 
 difference. If you're using PHP5, just use
 microtime(TRUE); to get the 
 float value.
 
 -- 
 
 ---John Holmes...
 
 Amazon Wishlist:
 www.amazon.com/o/registry/3BEXC84AB3A5E/
 
 php|architect: The Magazine for PHP Professionals –
 www.phparch.com
 
 
 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Time consumed in microseconds

2004-08-31 Thread raditha dissanayake
Karam Chand wrote:
Darn missed it. Looking into the docs I am using code
somthing like this:
 

If you are really keen about chaning +1 to ++  and double quotes to 
single quotes in the hope of shaving off a few milliseconds in execution 
time you might want to try something like xdebug.

--
Raditha Dissanayake.

http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Time consumed in microseconds

2004-08-30 Thread Karam Chand
Hello,

In Win32 API to profile a job we use the following
method:


 timetaken = GetTickCount();
 /* do some job */
 timetaken = GetTickCount() - timetaken;

In this way timetaken returns you the time taken by
the job to complete?

How can I get it in PHP. I want the exact figure in
ms? I used microtime() and the samples given in
php.net but none of them correctly returns the
difference only in ms?
 
Regards,
Karam   




___
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
http://promotions.yahoo.com/goldrush

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Time consumed in microseconds

2004-08-30 Thread John Holmes
Karam Chand wrote:
In Win32 API to profile a job we use the following
method:
 timetaken = GetTickCount();
 /* do some job */
 timetaken = GetTickCount() - timetaken;
In this way timetaken returns you the time taken by
the job to complete?
How can I get it in PHP. I want the exact figure in
ms? I used microtime() and the samples given in
php.net but none of them correctly returns the
difference only in ms?
Read the manual page again. Use the example to get the microtime as a 
float at the start and then after your job. Subtract to get the 
difference. If you're using PHP5, just use microtime(TRUE); to get the 
float value.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php