Merge branch 'charm' of charmgit:charm into charm
[charm.git] / src / ck-ldb / tm_timings.h
1 #ifndef TIMINGS_H
2 #define TIMINGS_H
3
4 #ifndef _WIN32
5 #include <sys/time.h>
6 #else
7 #include <sys/timeb.h>
8 #endif
9 #include <stdlib.h>
10 #include <unistd.h>
11
12 #define MAX_CLOCK 100
13
14 #ifndef _WIN32
15 typedef struct timeval CLOCK_T;
16
17 #define CLOCK(c) gettimeofday(&c,(struct timezone *)NULL)
18 #define CLOCK_DIFF(c1,c2)  \
19 ((double)(c1.tv_sec-c2.tv_sec)+(double)(c1.tv_usec-c2.tv_usec)/1e+6)
20 #define CLOCK_DISPLAY(c) fprintf(stderr,"%d.%d",(int)c.tv_sec,(int)c.tv_usec)
21
22 #else    /* for windows */
23
24 #ifdef __CYGWIN__
25 typedef struct timeb CLOCK_T;
26 #else
27 typedef struct _timeb CLOCK_T;
28 #endif
29
30 #define CLOCK(c) _ftime(&c)
31 #define CLOCK_DIFF(c1,c2)  \
32 ((double)(c1.time-c2.time)+(double)(c1.millitm-c2.millitm)/1e+3)
33 #define CLOCK_DISPLAY(c) fprintf(stderr,"%d.%d",(int)c.time,(int)c.millitm*1e+3)
34 #endif
35
36 double time_diff();
37 void get_time();
38
39 #define TIC get_time()
40 #define TOC time_diff()
41
42 #endif /*TIMINGS_H*/
43