[thelist] Calculating Times in PHP
Joe Crawford
jcrawford at avencom.com
Mon Jun 11 18:41:07 CDT 2001
Poojie wrote:
> I'm attempting to time functions in PHP, but I keep getting
> negative values. I use the following function to get the time
> before and after the function I want to time has been called:
>
> function time_now(){
> list($usec, $sec) = explode(" ",microtime());
> return ((float)$usec + (float)$sec);
> }
>
> The timing code looks something like this:
>
> $t_start = time_now(); // Start Time
> func_to_time(); // Some action
> $t_end = time_now(); // End Time
>
> $t_total = $t_end - $t_start; // Total time passed
>
> How is it possible that roughly 1/2 of the result times turn up
> negative?
No idea - have you tried the code from here verbatim?
http://www.php.net/manual/en/function.microtime.php -- it looks similar
but not the same to yours. Does it also generate negative values?
- Joe
--
................... Joe Crawford \\ Web Design & Development
..... mailto:jcrawford at avencom.com \\ http://www.avencom.com
.... San Diego \\ CA \\ USA \\ AVENCOM: Set Your Sites Higher
More information about the thelist
mailing list