From: Jens Axboe Date: Fri, 21 Oct 2005 15:57:23 +0000 (+0200) Subject: [PATCH] fio: time cleanups X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=be33abe49fc3f38e73b57bf904c0915505301454;p=disktools.git [PATCH] fio: time cleanups --- diff --git a/fio.c b/fio.c index f507f30..3a21fab 100644 --- a/fio.c +++ b/fio.c @@ -279,6 +279,14 @@ static unsigned long mtime_since(struct timeval *s, struct timeval *e) return sec + usec; } +static unsigned long mtime_since_now(struct timeval *s) +{ + struct timeval t; + + gettimeofday(&t, NULL); + return mtime_since(s, &t); +} + static inline unsigned long msec_now(struct timeval *s) { return s->tv_sec * 1000 + s->tv_usec / 1000; @@ -672,7 +680,6 @@ static int init_aio(struct thread_data *td) static void *thread_main(int shm_id, int offset, char *argv[]) { struct thread_data *td; - struct timeval end; void *data, *ptr = NULL; struct stat st; int ret = 1, flags; @@ -756,11 +763,8 @@ static void *thread_main(int shm_id, int offset, char *argv[]) do_async_io(td); } - gettimeofday(&end, NULL); - td->runtime = mtime_since(&td->start, &end); - + td->runtime = mtime_since_now(&td->start); ret = 0; - err: shutdown_stat_file(td); if (td->use_aio) @@ -1305,7 +1309,7 @@ static void reap_threads(int *nr_running, int *t_rate, int *m_rate) static void run_threads(char *argv[]) { - struct timeval genesis, now; + struct timeval genesis; struct thread_data *td; unsigned long spent; int i, todo, nr_running, m_rate, t_rate; @@ -1338,8 +1342,7 @@ static void run_threads(char *argv[]) } if (td->start_delay) { - gettimeofday(&now, NULL); - spent = mtime_since(&genesis, &now); + spent = mtime_since_now(&genesis); if (td->start_delay * 1000 > spent) continue;