better section detection
[tridge/junkcode.git] / time_speed.c
1 #include <stdlib.h>
2 #include <stdio.h>
3
4 int main(void)
5 {
6         int i;
7         time_t t, t2;
8         struct timeval tv, tv2;
9
10         t = time(NULL);
11
12         i=0;
13
14         while (1) {
15                 t2 = time(NULL);
16                 i++;
17                 if (t2 - t > 10) break;
18         }
19         
20         printf("time(): %g ops/sec\n", (1.0*i) / (t2-t));
21
22
23         gettimeofday(&tv, NULL);
24         i=0;
25
26         while (1) {
27                 gettimeofday(&tv2, NULL);
28                 i++;
29                 if (tv2.tv_sec - tv.tv_sec > 10) break;
30         }
31         
32         printf("gettimeofday(): %g ops/sec\n", (1.0*i) / (tv2.tv_sec - tv.tv_sec));
33         return 0;
34 }