From 142362dd8ab5db6c67544f3e6b932eedc9b79f42 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Fri, 29 Apr 2011 17:30:17 +0200 Subject: [PATCH] A better timed speed test -T. --- INSTALL | 4 +- speed.c | 112 ++++++++++++++++++++++++-------------------------------- 2 files changed, 50 insertions(+), 66 deletions(-) diff --git a/INSTALL b/INSTALL index bc76ddd2..c63ddb6c 100644 --- a/INSTALL +++ b/INSTALL @@ -6,7 +6,7 @@ As root or user type: ./configure make -When you have to check for correctness the application simply typing: +When you have to check for correctness the application typing: make check @@ -19,7 +19,7 @@ To start using SnapRAID you have to change the example configuration file snapraid.conf.example to fit your needs and copy it in /etc/snapraid.conf To get more help, see the "Getting Started" section in the snapraid manpage -simply typing: +typing: man snapraid diff --git a/speed.c b/speed.c index 3288d28e..a098ed5f 100644 --- a/speed.c +++ b/speed.c @@ -22,6 +22,33 @@ #include "raid.h" #include "cpu.h" +/** + * Differential us of two timeval. + */ +static int64_t diffgettimeofday(struct timeval* start, struct timeval* stop) +{ + return 1000000LL * (stop->tv_sec - start->tv_sec) + stop->tv_usec - start->tv_usec; +} + +/** + * Start time measurement. + */ +#define SPEED_START \ + count = 0; \ + gettimeofday(&start, 0); \ + do { \ + for(i=0;i