On Wed, 19 Jan 2000, Sabrina Minshall wrote:
> What's going one here? Successive calls to gettimeofday
> yields negative elapsed time?
I'm sorry, but this is plain bad math. If the samples t1 and t2 were
taken in that order from a monotonically increasing value, then
> s = t1->tv_sec - t2->tv_sec;
> assert((s >= 0));
and
> ms = s * 1000000 + (t1->tv_usec - t2->tv_usec);
will never be positive. If t2 >= t1, then t1 - t2 <= 0. If time was truly
moving backwards on your system, then your assertion would succeed instead
of fail.
I think you will find everything is working properly if you reverse the
arguments to time_elapsed().
Doug White | FreeBSD: The Power to Serve
[EMAIL PROTECTED] | www.FreeBSD.org
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message