From 4ff530a4be17141a84616df8ea8546ffb47d6a2d Mon Sep 17 00:00:00 2001 From: pschwan Date: Tue, 24 Dec 2002 23:15:49 +0000 Subject: [PATCH] Add a statmany.c file to complement createmany.c Some day I'll clean up this directory, I swear it. --- lustre/tests/statmany.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 lustre/tests/statmany.c diff --git a/lustre/tests/statmany.c b/lustre/tests/statmany.c new file mode 100644 index 0000000..a291ebf --- /dev/null +++ b/lustre/tests/statmany.c @@ -0,0 +1,58 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char ** argv) +{ + int i, count, iter; + long int start, last, rc = 0; + + if (argc != 4) { + printf("Usage %s filenamebase file_count iterations\n", + argv[0]); + exit(1); + } + + if (strlen(argv[1]) > 4080) { + printf("name too long\n"); + exit(1); + } + + count = strtoul(argv[2], NULL, 0); + iter = strtoul(argv[3], NULL, 0); + + start = last = time(0); + + for (i = 0; i < iter; i++) { + struct stat buf; + char filename[4096]; + int tmp; + + tmp = random() % count; + sprintf(filename, "%s-%d", argv[1], tmp); + + rc = stat(filename, &buf); + if (rc) { + printf("stat(%s) error: %s\n", filename, + strerror(errno)); + break; + } + + if ((i % 10000) == 0) { + printf(" - stat %d (time %ld ; total %ld ; last %ld)\n", + i, time(0), time(0) - start, time(0) - last); + last = time(0); + } + } + + printf("total: %d stats in %ld seconds: %f stats/second\n", i, + time(0) - start, ((float)i / (time(0) - start))); + + exit(rc); +} -- 1.8.3.1