[PATCH] fio: time cleanups
authorJens Axboe <axboe@suse.de>
Fri, 21 Oct 2005 15:57:23 +0000 (17:57 +0200)
committerJens Axboe <axboe@suse.de>
Fri, 21 Oct 2005 15:57:23 +0000 (17:57 +0200)
fio.c

diff --git a/fio.c b/fio.c
index f507f3017fe5a5b089c40cac8692ebd6d5be6d21..3a21fabe6f919d0201dfb713a19c81dc36ea3daa 100644 (file)
--- 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;