fixed for VC++ windows
[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
18 #define CLOCK(c) gettimeofday(&c,(struct timezone *)NULL)
19 #define CLOCK_DIFF(c1,c2)  \
20 ((double)(c1.tv_sec-c2.tv_sec)+(double)(c1.tv_usec-c2.tv_usec)/1e+6)
21 #define CLOCK_DISPLAY(c) fprintf(stderr,"%d.%d",(int)c.tv_sec,(int)c.tv_usec)
22
23 #else    /* for windows */
24
25 #ifdef __CYGWIN__
26 typedef struct timeb CLOCK_T;
27 #else
28 typedef struct _timeb CLOCK_T;
29 #endif
30
31 #define CLOCK(c) _ftime(&c)
32 #define CLOCK_DIFF(c1,c2)  \
33 ((double)(c1.time-c2.time)+(double)(c1.millitm-c2.millitm)/1e+3)
34 #define CLOCK_DISPLAY(c) fprintf(stderr,"%d.%d",(int)c.time,(int)c.millitm*1e+3)
35
36 #endif
37
38 double time_diff();
39 void get_time();
40
41 #define TIC get_time()
42 #define TOC time_diff()
43
44 #endif /*TIMINGS_H*/
45