]> git.itanic.dy.fi Git - membench/blobdiff - membench.c
Add cast to suppress compile warnings on both 32 and 64 bit architectures
[membench] / membench.c
index 53b967bafea35a15909011d1488556b7860bf613..4aaa8b9745656e2726839a86b984cb6387969b7b 100644 (file)
@@ -4,9 +4,9 @@
 
 #define lsize sizeof(unsigned long)
 
-long usec_diff(const struct timeval *a, const struct timeval *b)
+long long usec_diff(const struct timeval *a, const struct timeval *b)
 {
-       long usec_a, usec_b;
+       long long usec_a, usec_b;
        usec_a = a->tv_sec * 1000000 + a->tv_usec;
        usec_b = b->tv_sec * 1000000 + b->tv_usec;
        return usec_b - usec_a;
@@ -18,6 +18,9 @@ int main(int argc, char *argv[])
        unsigned long *buf, i, tmp = 0;
        struct timeval start, end;
 
+       printf("Benchmark sequential access bandwidth "
+               "and random access latency\n\n");
+
        if (argc > 1)
                iterations = atoi(argv[1]);
        else
@@ -32,7 +35,7 @@ int main(int argc, char *argv[])
        printf("Doing %d runs with buffer size goin up to %dk\n",
               iterations, 1 << (iterations - 10));
        printf("Running each round %d times\n", count);
-       printf("Size of unsigned long is %lu bits\n\n", lsize * 8);
+       printf("Size of unsigned long is %d bits\n\n", (int)lsize * 8);
 
        switch (lsize) {
        case 4:
@@ -74,7 +77,7 @@ int main(int argc, char *argv[])
                for (i = 0; i < size; i++)
                        buf[i] = i;
 
-               printf("%8luk |", size * lsize / 1024);
+               printf("%8dk |", (int)(size * lsize / 1024));
 
                /* Read bandwidth*/
 
@@ -124,6 +127,7 @@ int main(int argc, char *argv[])
                       (1000000 / (1024.0 * 1024.0)) * count / 
                       (double) usec_diff(&start, &end));
        
+               fflush(stdout);
 
                /* Write latency */