summaryrefslogtreecommitdiff
path: root/libm/double/time-it.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-05-10 00:40:28 +0000
committerEric Andersen <andersen@codepoet.org>2001-05-10 00:40:28 +0000
commit1077fa4d772832f77a677ce7fb7c2d513b959e3f (patch)
tree579bee13fb0b58d2800206366ec2caecbb15f3fc /libm/double/time-it.c
parent22358dd7ce7bb49792204b698f01a6f69b9c8e08 (diff)
uClibc now has a math library. muahahahaha!
-Erik
Diffstat (limited to 'libm/double/time-it.c')
-rw-r--r--libm/double/time-it.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/libm/double/time-it.c b/libm/double/time-it.c
new file mode 100644
index 000000000..32d07db4e
--- /dev/null
+++ b/libm/double/time-it.c
@@ -0,0 +1,38 @@
+/* Reports run time, in seconds, for a command.
+ The command argument can have multiple words, but then
+ it has to be quoted, as for example
+
+ time-it "command < file1 > file2"
+
+ The time interval resolution is one whole second. */
+
+
+#include <time.h>
+int system ();
+int printf ();
+
+int
+main (argv, argc)
+ int argv;
+ char **argc;
+{
+ time_t t0, t1;
+
+ if (argv < 2)
+ {
+ printf ("Usage: time-it name_of_program_to_be_timed\n");
+ exit (1);
+ }
+ time (&t0);
+ /* Wait til the clock changes before starting. */
+ do
+ {
+ time (&t1);
+ }
+ while (t1 == t0);
+ system (argc[1]);
+ t0 = t1;
+ time (&t1);
+ printf ("%ld seconds.\n", t1 - t0);
+ exit (0);
+}