time: add ntime_since_now()
authorJens Axboe <axboe@kernel.dk>
Mon, 9 Oct 2017 18:58:26 +0000 (12:58 -0600)
committerJens Axboe <axboe@kernel.dk>
Mon, 9 Oct 2017 18:58:26 +0000 (12:58 -0600)
Convert filecreate engine to using it as well.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
engines/filecreate.c
fio_time.h
gettime.c

index 01f7d68f4073e0fe41131fd5652e5604b5161b21..d753df24c94f830b6ef581a754677a8c0212b1ff 100644 (file)
@@ -14,7 +14,7 @@
 
 static int open_file(struct thread_data *td, struct fio_file *f)
 {
 
 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);
        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) {
        }
 
        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);
        }
 
                add_lat_sample(td, DDIR_WRITE, nsec, 0, 0);
        }
 
index f4eac793f4fb3311dbd77069fc5a392477f33fef..c7c3dbbad957240d5371e77967f7486b0dd028e3 100644 (file)
@@ -5,6 +5,7 @@
 
 struct thread_data;
 extern uint64_t ntime_since(const struct timespec *, const struct timespec *);
 
 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 *);
 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 *);
index 3dcaaf680803fdcdb798de6009745f7821118d39..79455284a30d715b819a779bf3e7943c602eb549 100644 (file)
--- 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);
 }
 
        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;
 uint64_t utime_since(const struct timespec *s, const struct timespec *e)
 {
        int64_t sec, usec;