gettime: Simplify get_cycles_per_msec()
authorBart Van Assche <bvanassche@acm.org>
Mon, 7 Sep 2020 22:55:27 +0000 (15:55 -0700)
committerBart Van Assche <bvanassche@acm.org>
Sun, 20 Sep 2020 23:09:45 +0000 (16:09 -0700)
Call fio_get_mono_time() directly instead of setting fio_clock_source and
calling __fio_gettime().

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
gettime.c

index 6b202e8f5e29239b381d0c99391bb080f2eac948..fcb536d079160eadf6b896bf6e31438f5bf8d171 100644 (file)
--- a/gettime.c
+++ b/gettime.c
@@ -239,19 +239,13 @@ static unsigned long get_cycles_per_msec(void)
 {
        struct timespec s, e;
        uint64_t c_s, c_e;
-       enum fio_cs old_cs = fio_clock_source;
        uint64_t elapsed;
 
-#ifdef CONFIG_CLOCK_GETTIME
-       fio_clock_source = CS_CGETTIME;
-#else
-       fio_clock_source = CS_GTOD;
-#endif
-       __fio_gettime(&s);
+       fio_get_mono_time(&s);
 
        c_s = get_cpu_clock();
        do {
-               __fio_gettime(&e);
+               fio_get_mono_time(&e);
                c_e = get_cpu_clock();
 
                elapsed = ntime_since(&s, &e);
@@ -259,7 +253,6 @@ static unsigned long get_cycles_per_msec(void)
                        break;
        } while (1);
 
-       fio_clock_source = old_cs;
        return (c_e - c_s) * 1000000 / elapsed;
 }