00001 #ifndef TIMINGS_H
00002 #define TIMINGS_H
00003 #include <stdio.h>
00004
00005 #ifndef _WIN32
00006 #include <sys/time.h>
00007 #else
00008 #include <sys/timeb.h>
00009 #endif
00010 #include <stdlib.h>
00011 #include <unistd.h>
00012
00013 #define MAX_CLOCK 100
00014
00015 #ifndef _WIN32
00016 typedef struct timeval CLOCK_T;
00017
00018
00019 #define CLOCK(c) gettimeofday(&c,(struct timezone *)NULL)
00020 #define CLOCK_DIFF(c1,c2) \
00021 ((double)(c1.tv_sec-c2.tv_sec)+(double)(c1.tv_usec-c2.tv_usec)/1e+6)
00022 #define CLOCK_DISPLAY(c) fprintf(stderr,"%d.%d",(int)c.tv_sec,(int)c.tv_usec)
00023
00024 #else
00025
00026 #ifdef __CYGWIN__
00027 typedef struct timeb CLOCK_T;
00028 #else
00029 typedef struct _timeb CLOCK_T;
00030 #endif
00031
00032 #define CLOCK(c) _ftime(&c)
00033 #define CLOCK_DIFF(c1,c2) \
00034 ((double)(c1.time-c2.time)+(double)(c1.millitm-c2.millitm)/1e+3)
00035 #define CLOCK_DISPLAY(c) fprintf(stderr,"%d.%d",(int)c.time,(int)c.millitm*1e+3)
00036
00037 #endif
00038
00039 double time_diff();
00040 void get_time();
00041
00042 #define TIC get_time()
00043 #define TOC time_diff()
00044
00045 #endif
00046