microtime on Win32
| From: | Sascha Schumann | Date: | Mon, 20 Sep 1999 16:46:24 +0000 |
| Subject: | microtime on Win32 | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-11108@lists.php.net to get a copy of this message | ||
gettimeofday() on Win32 seems to return values larger than
1e6 in tv_usec which causes the output of microtime to look
"strange."
If noone objects, I'll commit the attached patch which
should cause the format of the return value to be equal on
all platforms.
--
Regards,
Sascha Schumann
Consultant
Index: microtime.c =================================================================== RCS file: /repository/php3/functions/microtime.c,v retrieving revision 1.31 diff -u -r1.31 microtime.c --- microtime.c 1999/06/16 11:34:21 1.31 +++ microtime.c 1999/09/20 16:39:54 @@ -81,6 +81,7 @@ msec = (double) (tp.tv_usec / MICRO_IN_SEC); sec = tp.tv_sec; } + if (msec > 1.0) msec -= (long) msec; snprintf(ret, 100, "%.8f %ld", msec, sec); RETVAL_STRING(ret,1); #endif
Index: microtime.c =================================================================== RCS file: /repository/php3/functions/microtime.c,v retrieving revision 1.31 diff -u -r1.31 microtime.c --- microtime.c 1999/06/16 11:34:21 1.31 +++ microtime.c 1999/09/20 16:39:54 @@ -81,6 +81,7 @@ msec = (double) (tp.tv_usec / MICRO_IN_SEC); sec = tp.tv_sec; } + if (msec > 1.0) msec -= (long) msec; snprintf(ret, 100, "%.8f %ld", msec, sec); RETVAL_STRING(ret,1); #endif