From 795d1fd71dc4862b239cce0eddf77f8b4ae29f71 Mon Sep 17 00:00:00 2001 From: Stéphane Raimbault Date: Thu, 2 Apr 2009 19:00:02 +0200 Subject: [PATCH] Fix the bandwith computing when a longer delay is measured --- tests/bandwidth-master.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/tests/bandwidth-master.c b/tests/bandwidth-master.c index 0227b6c..1f455ef 100644 --- a/tests/bandwidth-master.c +++ b/tests/bandwidth-master.c @@ -26,15 +26,16 @@ /* Tests based on PI-MBUS-300 documentation */ #define SLAVE 0x11 -#define NB_LOOPS 10000 +#define NB_LOOPS 100000 -#define G_USEC_PER_SEC 1000000 -uint32_t gettime(void) +#define G_MSEC_PER_SEC 1000 + +uint32_t gettime_ms(void) { struct timeval tv; gettimeofday (&tv, NULL); - return (uint32_t) tv.tv_sec * G_USEC_PER_SEC + tv.tv_usec; + return (uint32_t) tv.tv_sec * 1000 + tv.tv_usec / 1000; } int main(void) @@ -69,20 +70,20 @@ int main(void) printf("READ COIL STATUS\n\n"); nb_points = MAX_STATUS; - start = gettime(); + start = gettime_ms(); for (i=0; i