-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
* GPL HEADER START
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* 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.
*/
/*
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/time.h>
#include <time.h>
#include <errno.h>
#include <string.h>
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;
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" */
usage(argv[0]);
}
- start = last = time(NULL);
+ start = last = now();
has_fmt_spec = strchr(fmt, '%') != NULL;
if (do_unlink)
}
}
- 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;
}