t/lfsr-test: fixup time
authorJens Axboe <axboe@fb.com>
Fri, 26 Sep 2014 16:01:50 +0000 (10:01 -0600)
committerJens Axboe <axboe@fb.com>
Fri, 26 Sep 2014 16:01:50 +0000 (10:01 -0600)
Signed-off-by: Jens Axboe <axboe@fb.com>
fio_time.h
t/lfsr-test.c

index c550a55b72a6e3d32153fa2e75815c9f1892418a..9f7d209a303f7987612923f456162fe5ce5d1d96 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef FIO_TIME_H
 #define FIO_TIME_H
 
 #ifndef FIO_TIME_H
 #define FIO_TIME_H
 
+struct thread_data;
 extern uint64_t utime_since(struct timeval *, struct timeval *);
 extern uint64_t utime_since_now(struct timeval *);
 extern uint64_t mtime_since(struct timeval *, struct timeval *);
 extern uint64_t utime_since(struct timeval *, struct timeval *);
 extern uint64_t utime_since_now(struct timeval *);
 extern uint64_t mtime_since(struct timeval *, struct timeval *);
index 2eee0c648e50aad5b3264f7407bc858dd4ad70cc..4b5424833ffca7ae148a6c696df3f97baaca83e5 100644 (file)
@@ -8,6 +8,8 @@
 #include <sys/stat.h>
 
 #include "../lib/lfsr.h"
 #include <sys/stat.h>
 
 #include "../lib/lfsr.h"
+#include "../gettime.h"
+#include "../fio_time.h"
 
 void usage()
 {
 
 void usage()
 {
@@ -25,7 +27,7 @@ void usage()
 int main(int argc, char *argv[])
 {
        int r;
 int main(int argc, char *argv[])
 {
        int r;
-       struct timespec start, end;
+       struct timeval start, end;
        struct fio_lfsr *fl;
        int verify = 0;
        unsigned int spin = 0;
        struct fio_lfsr *fl;
        int verify = 0;
        unsigned int spin = 0;
@@ -113,8 +115,7 @@ int main(int argc, char *argv[])
        }
 
        /* Calculate elapsed time and mean time per number */
        }
 
        /* Calculate elapsed time and mean time per number */
-       total = (end.tv_sec - start.tv_sec) * pow(10,9) +
-               end.tv_nsec - start.tv_nsec;
+       total = utime_since(&start, &end);
        mean = total / fl->num_vals;
 
        printf("\nTime results ");
        mean = total / fl->num_vals;
 
        printf("\nTime results ");
@@ -122,7 +123,7 @@ int main(int argc, char *argv[])
                printf("(slower due to verification)");
        printf("\n==============================\n");
        printf("Elapsed: %lf s\n", total / pow(10,9));
                printf("(slower due to verification)");
        printf("\n==============================\n");
        printf("Elapsed: %lf s\n", total / pow(10,9));
-       printf("Mean:    %lf ns\n", mean);
+       printf("Mean:    %lf us\n", mean);
 
        free(v_start);
        free(fl);
 
        free(v_start);
        free(fl);