From b6b01064279c0cf5bae8b2324c760f1f7f6be457 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 25 Nov 2004 23:05:43 +0000 Subject: r3976: changed NBENCH to use the same recording method as the latest dbench, where the warmup phase continues until all clients have done some file IO. This gives more repeatable results when under high load (This used to be commit aca0658f6dfe8b7c90afcac87e8cc68965a4288d) --- source4/lib/time.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/time.c b/source4/lib/time.c index b13ad24b34..8d477fac02 100644 --- a/source4/lib/time.c +++ b/source4/lib/time.c @@ -476,14 +476,22 @@ BOOL timeval_expired(struct timeval *tv) return (tv2.tv_usec >= tv->tv_usec); } +/* + return the number of seconds elapsed between two times +*/ +double timeval_elapsed2(struct timeval *tv1, struct timeval *tv2) +{ + return (tv2->tv_sec - tv1->tv_sec) + + (tv2->tv_usec - tv1->tv_usec)*1.0e-6; +} + /* return the number of seconds elapsed since a given time */ double timeval_elapsed(struct timeval *tv) { struct timeval tv2 = timeval_current(); - return (tv2.tv_sec - tv->tv_sec) + - (tv2.tv_usec - tv->tv_usec)*1.0e-6; + return timeval_elapsed2(tv, &tv2); } /* @@ -497,6 +505,17 @@ struct timeval timeval_min(struct timeval *tv1, struct timeval *tv2) return *tv2; } +/* + return the greater of two timevals +*/ +struct timeval timeval_max(struct timeval *tv1, struct timeval *tv2) +{ + if (tv1->tv_sec > tv2->tv_sec) return *tv1; + if (tv1->tv_sec < tv2->tv_sec) return *tv2; + if (tv1->tv_usec > tv2->tv_usec) return *tv1; + return *tv2; +} + /* return the difference between two timevals as a timeval if tv2 comes after tv1, then return a zero timeval -- cgit