X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fcreatemany.c;h=3151f2fe7cfadb15a7ee924867cb13cfeadedb8c;hb=09fe7811cb076a00a905b747d0048294a0ef2e4d;hp=a937fc525fd688995df0847dd5edbd98aef3587c;hpb=cc6c2e9d1ead204736cf7d6c2ea35d89dba2cd0b;p=fs%2Flustre-release.git diff --git a/lustre/tests/createmany.c b/lustre/tests/createmany.c index a937fc5..3151f2f 100644 --- a/lustre/tests/createmany.c +++ b/lustre/tests/createmany.c @@ -26,7 +26,7 @@ * GPL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. */ /* @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -67,6 +68,13 @@ static char *get_file_name(const char *fmt, long n, int has_fmt_spec) return filename; } +double now(void) +{ + struct timeval tv; + gettimeofday(&tv, NULL); + return (double)tv.tv_sec + (double)tv.tv_usec / 1000000; +} + int main(int argc, char ** argv) { long i; @@ -74,8 +82,8 @@ int main(int argc, char ** argv) int do_unlink = 0, do_mknod = 0; char *filename; char *fmt = NULL, *fmt_unlink = NULL, *tgt = NULL; - long start, last, end = ~0UL >> 1; - long begin = 0, count = ~0UL >> 1; + double start, last; + long begin = 0, end = ~0UL >> 1, count = ~0UL >> 1; int c, has_fmt_spec = 0, unlink_has_fmt_spec = 0; /* Handle the last argument in form of "-seconds" */ @@ -132,7 +140,7 @@ int main(int argc, char ** argv) usage(argv[0]); } - start = last = time(NULL); + start = last = now(); has_fmt_spec = strchr(fmt, '%') != NULL; if (do_unlink) @@ -186,15 +194,15 @@ int main(int argc, char ** argv) } } - if ((i % 10000) == 0) { - printf(" - created %ld (time %ld total %ld last %ld)\n", - i, time(0), time(0) - start, time(0) - last); - last = time(NULL); + if (i && (i % 10000) == 0) { + printf(" - created %ld (time %.2f total %.2f last %.2f)" + "\n", i, now(), now() - start, now() - last); + last = now(); } } - printf("total: %ld creates%s in %ld seconds: %f creates/second\n", i, + printf("total: %ld creates%s in %.2f seconds: %.2f creates/second\n", i, do_unlink ? "/deletions" : "", - time(NULL) - start, ((float)i / (time(0) - start))); + now() - start, ((double)i / (now() - start))); return rc; }