summaryrefslogtreecommitdiff
path: root/libm/double/time-it.c
blob: 32d07db4ea335442626280291bc94c6f30365c69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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);
}