t/io_uring: only call setrlimit() for fixedbufs
[fio.git] / t / lfsr-test.c
index 2eee0c648e50aad5b3264f7407bc858dd4ad70cc..a01f2cfcb43c2cf963f69675bd462eb7f0f2fa33 100644 (file)
@@ -1,15 +1,13 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <time.h>
 #include <math.h>
 #include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
 
 #include "../lib/lfsr.h"
+#include "../gettime.h"
+#include "../fio_time.h"
 
-void usage()
+static void usage(void)
 {
        printf("Usage: lfsr-test 0x<numbers> [seed] [spin] [verify]\n");
        printf("-------------------------------------------------------------\n");
@@ -36,6 +34,8 @@ int main(int argc, char *argv[])
        void *v = NULL, *v_start;
        double total, mean;
 
+       arch_init(argv);
+
        /* Read arguments */
        switch (argc) {
                case 5: if (strncmp(argv[4], "verify", 7) == 0)
@@ -76,7 +76,7 @@ int main(int argc, char *argv[])
                v_size = numbers * sizeof(uint8_t);
                v = malloc(v_size);
                memset(v, 0, v_size);
-               printf("\nVerification table is %lf KBs\n", (double)(v_size) / 1024);
+               printf("\nVerification table is %lf KiB\n", (double)(v_size) / 1024);
        }
        v_start = v;
 
@@ -87,7 +87,7 @@ int main(int argc, char *argv[])
         */
        fprintf(stderr, "\nTest initiated... ");
        fio_gettime(&start, NULL);
-       while (!lfsr_next(fl, &i, fl->max_val)) {
+       while (!lfsr_next(fl, &i)) {
                if (verify)
                        *(uint8_t *)(v + i) += 1;
        }
@@ -113,16 +113,15 @@ int main(int argc, char *argv[])
        }
 
        /* 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 ");
        if (verify)
                printf("(slower due to verification)");
        printf("\n==============================\n");
-       printf("Elapsed: %lf s\n", total / pow(10,9));
-       printf("Mean:    %lf ns\n", mean);
+       printf("Elapsed: %lf s\n", total / pow(10,6));
+       printf("Mean:    %lf us\n", mean);
 
        free(v_start);
        free(fl);