X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=gettime.c;h=628aad640810e4c01ef2892bd6c2158c0d5c84a2;hb=d1419c4f019c6dead07f19326a6db20b93e4542b;hp=964a52fa237afe50a05cd7d9081c3e29c26c70fc;hpb=be6bb2b72608d7efbec13d06c67446e229136afa;p=fio.git diff --git a/gettime.c b/gettime.c index 964a52fa..628aad64 100644 --- a/gettime.c +++ b/gettime.c @@ -381,8 +381,7 @@ void fio_clock_init(void) uint64_t utime_since(const struct timeval *s, const struct timeval *e) { - long sec, usec; - uint64_t ret; + int64_t sec, usec; sec = e->tv_sec - s->tv_sec; usec = e->tv_usec - s->tv_usec; @@ -397,22 +396,26 @@ uint64_t utime_since(const struct timeval *s, const struct timeval *e) if (sec < 0 || (sec == 0 && usec < 0)) return 0; - ret = sec * 1000000ULL + usec; - - return ret; + return usec + (sec * 1000000); } uint64_t utime_since_now(const struct timeval *s) { struct timeval t; +#ifdef FIO_DEBUG_TIME + void *p = __builtin_return_address(0); + fio_gettime(&t, p); +#else fio_gettime(&t, NULL); +#endif + return utime_since(s, &t); } uint64_t mtime_since(const struct timeval *s, const struct timeval *e) { - long sec, usec, ret; + long sec, usec; sec = e->tv_sec - s->tv_sec; usec = e->tv_usec - s->tv_usec; @@ -426,17 +429,20 @@ uint64_t mtime_since(const struct timeval *s, const struct timeval *e) sec *= 1000; usec /= 1000; - ret = sec + usec; - - return ret; + return sec + usec; } uint64_t mtime_since_now(const struct timeval *s) { struct timeval t; +#ifdef FIO_DEBUG_TIME void *p = __builtin_return_address(0); fio_gettime(&t, p); +#else + fio_gettime(&t, NULL); +#endif + return mtime_since(s, &t); }