X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=gettime.c;h=85ba7cba8954aa3a70ae5e1faf9a76ab6ab22c72;hp=922768ebe5fce2d6738a27a3fe2e54533a527950;hb=a09986004635b75f82c13c0674bae671a89fb065;hpb=99afcdb53dc388edcc1270fe2f76d8ce1a3f9f3c diff --git a/gettime.c b/gettime.c index 922768eb..85ba7cba 100644 --- a/gettime.c +++ b/gettime.c @@ -253,7 +253,7 @@ static unsigned long get_cycles_per_usec(void) } while (1); fio_clock_source = old_cs; - return ((c_e - c_s) * 10) / elapsed; + return (c_e - c_s) / elapsed; } #define NR_TIME_ITERS 50 @@ -299,16 +299,11 @@ static int calibrate_cpu_clock(void) } S /= (double) NR_TIME_ITERS; - mean /= 10.0; for (i = 0; i < NR_TIME_ITERS; i++) - dprint(FD_TIME, "cycles[%d]=%llu\n", i, - (unsigned long long) cycles[i] / 10); + dprint(FD_TIME, "cycles[%d]=%llu\n", i, (unsigned long long) cycles[i]); avg /= samples; - avg = (avg + 5) / 10; - minc /= 10; - maxc /= 10; dprint(FD_TIME, "avg: %llu\n", (unsigned long long) avg); dprint(FD_TIME, "min=%llu, max=%llu, mean=%f, S=%f\n", (unsigned long long) minc, @@ -386,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; @@ -402,9 +396,7 @@ 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) @@ -417,7 +409,7 @@ uint64_t utime_since_now(const struct timeval *s) 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; @@ -429,11 +421,9 @@ uint64_t mtime_since(const struct timeval *s, const struct timeval *e) if (sec < 0 || (sec == 0 && usec < 0)) return 0; - sec *= 1000UL; - usec /= 1000UL; - ret = sec + usec; - - return ret; + sec *= 1000; + usec /= 1000; + return sec + usec; } uint64_t mtime_since_now(const struct timeval *s)