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 typedef struct _timeb CLOCK_T;
00027
00028 #define CLOCK(c) _ftime(&c)
00029 #define CLOCK_DIFF(c1,c2) \
00030 ((double)(c1.time-c2.time)+(double)(c1.millitm-c2.millitm)/1e+3)
00031 #define CLOCK_DISPLAY(c) fprintf(stderr,"%d.%d",(int)c.time,(int)c.millitm*1e+3)
00032
00033 #endif
00034
00035 double time_diff();
00036 void get_time();
00037
00038 #define TIC get_time()
00039 #define TOC time_diff()
00040
00041 #endif
00042