From 152529ae26d1167779138b6cd30d4de10623da1b Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 27 Sep 2018 17:38:21 -0600 Subject: [PATCH] gettime: slightly improve CPU clock calibration We should not factor the utime_since() runtime into this, so do the get_cpu_clock() before. In reality this probably won't make any difference, as we're doing this tight loop for more than a milisecond. Signed-off-by: Jens Axboe --- gettime.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gettime.c b/gettime.c index c0f26382..7702193d 100644 --- a/gettime.c +++ b/gettime.c @@ -237,12 +237,11 @@ static unsigned long get_cycles_per_msec(void) c_s = get_cpu_clock(); do { __fio_gettime(&e); + c_e = get_cpu_clock(); elapsed = utime_since(&s, &e); - if (elapsed >= 1280) { - c_e = get_cpu_clock(); + if (elapsed >= 1280) break; - } } while (1); fio_clock_source = old_cs; -- 2.25.1