2015-01-05 Steve Ellcey <sellcey@imgtec.com>
[glibc.git] / time / clocktest.c
blob2e6457d56a6b74e7eb180353515a6c6fa15a5d17
1 #include <signal.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <time.h>
5 #include <unistd.h>
7 volatile int gotit = 0;
9 static void
10 alarm_handler (int signal)
12 gotit = 1;
16 int
17 main (int argc, char ** argv)
19 clock_t start, stop;
21 if (signal(SIGALRM, alarm_handler) == SIG_ERR)
23 perror ("signal");
24 exit (1);
26 alarm(1);
27 start = clock ();
28 while (!gotit);
29 stop = clock ();
31 printf ("%jd clock ticks per second (start=%jd,stop=%jd)\n",
32 (intmax_t) (stop - start), (intmax_t) start, (intmax_t) stop);
33 printf ("CLOCKS_PER_SEC=%ld, sysconf(_SC_CLK_TCK)=%ld\n",
34 CLOCKS_PER_SEC, sysconf(_SC_CLK_TCK));
35 return 0;