From 0410e7834e18760c4b38d8e51483c649d47aa0c0 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 9 Oct 2017 12:58:26 -0600 Subject: [PATCH 1/1] time: add ntime_since_now() Convert filecreate engine to using it as well. Signed-off-by: Jens Axboe --- engines/filecreate.c | 7 +++---- fio_time.h | 1 + gettime.c | 8 ++++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/engines/filecreate.c b/engines/filecreate.c index 01f7d68f..d753df24 100644 --- a/engines/filecreate.c +++ b/engines/filecreate.c @@ -14,7 +14,7 @@ static int open_file(struct thread_data *td, struct fio_file *f) { - struct timespec start, end; + struct timespec start; int do_lat = !td->o.disable_lat; dprint(FD_FILE, "fd open %s\n", f->file_name); @@ -43,10 +43,9 @@ static int open_file(struct thread_data *td, struct fio_file *f) } if (do_lat) { - unsigned long long nsec; + uint64_t nsec; - fio_gettime(&end, NULL); - nsec = ntime_since(&start, &end); + nsec = ntime_since_now(&start); add_lat_sample(td, DDIR_WRITE, nsec, 0, 0); } diff --git a/fio_time.h b/fio_time.h index f4eac793..c7c3dbba 100644 --- a/fio_time.h +++ b/fio_time.h @@ -5,6 +5,7 @@ struct thread_data; extern uint64_t ntime_since(const struct timespec *, const struct timespec *); +extern uint64_t ntime_since_now(const struct timespec *); extern uint64_t utime_since(const struct timespec *, const struct timespec *); extern uint64_t utime_since_now(const struct timespec *); extern uint64_t mtime_since(const struct timespec *, const struct timespec *); diff --git a/gettime.c b/gettime.c index 3dcaaf68..79455284 100644 --- a/gettime.c +++ b/gettime.c @@ -448,6 +448,14 @@ uint64_t ntime_since(const struct timespec *s, const struct timespec *e) return nsec + (sec * 1000000000LL); } +uint64_t ntime_since_now(const struct timespec *s) +{ + struct timespec now; + + fio_gettime(&now, NULL); + return ntime_since(s, &now); +} + uint64_t utime_since(const struct timespec *s, const struct timespec *e) { int64_t sec, usec; -- 2.25.1