Skip to content

Commit

Permalink
time: add ntime_since_now()
Browse files Browse the repository at this point in the history
Convert filecreate engine to using it as well.

Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Oct 9, 2017
1 parent 084a547 commit 0410e78
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
7 changes: 3 additions & 4 deletions engines/filecreate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions fio_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down
8 changes: 8 additions & 0 deletions gettime.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0410e78

Please sign in to comment.