]> git.ipfire.org Git - thirdparty/glibc.git/blame - time/clocktest.c
Installed-header hygiene (BZ#20366): time.h types.
[thirdparty/glibc.git] / time / clocktest.c
CommitLineData
84724245 1#include <signal.h>
28f540f4 2#include <stdio.h>
3e1f480e 3#include <stdlib.h>
28f540f4 4#include <time.h>
84724245 5#include <unistd.h>
28f540f4 6
84724245
RM
7volatile int gotit = 0;
8
de149cdb 9static void
84724245
RM
10alarm_handler (int signal)
11{
12 gotit = 1;
13}
14
15
16int
17main (int argc, char ** argv)
28f540f4 18{
84724245 19 clock_t start, stop;
28f540f4 20
227d9931 21 if (signal(SIGALRM, alarm_handler) == SIG_ERR)
9eb2730e
UD
22 {
23 perror ("signal");
24 exit (1);
25 }
84724245
RM
26 alarm(1);
27 start = clock ();
28 while (!gotit);
29 stop = clock ();
28f540f4 30
fe342f50
L
31 printf ("%jd clock ticks per second (start=%jd,stop=%jd)\n",
32 (intmax_t) (stop - start), (intmax_t) start, (intmax_t) stop);
57ada0e7
L
33 printf ("CLOCKS_PER_SEC=%jd, sysconf(_SC_CLK_TCK)=%ld\n",
34 (intmax_t) CLOCKS_PER_SEC, sysconf(_SC_CLK_TCK));
28f540f4
RM
35 return 0;
36}