aboutsummaryrefslogtreecommitdiff
path: root/testdir/time.c
diff options
context:
space:
mode:
Diffstat (limited to 'testdir/time.c')
-rw-r--r--testdir/time.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/testdir/time.c b/testdir/time.c
new file mode 100644
index 000000000000..607b470c90f5
--- /dev/null
+++ b/testdir/time.c
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/times.h>
+#include <time.h>
+
+int main(int argc, char *argv[])
+{
+ struct tms before, after;
+ char cmd[10000];
+ int i;
+ double fudge = 100.0; /* should be CLOCKS_PER_SEC but that gives nonsense */
+
+ times(&before);
+
+ /* ... place code to be timed here ... */
+ cmd[0] = 0;
+ for (i = 1; i < argc; i++)
+ sprintf(cmd+strlen(cmd), "%s ", argv[i]);
+ sprintf(cmd+strlen(cmd), "\n");
+ /* printf("cmd = [%s]\n", cmd); */
+ system(cmd);
+
+ times(&after);
+
+ fprintf(stderr, "user %6.3f\n", (after.tms_cutime - before.tms_cutime)/fudge);
+ fprintf(stderr, "sys %6.3f\n", (after.tms_cstime - before.tms_cstime)/fudge);
+
+ return 0;
+}