00001 00015 #include "global.h" 00016 00017 00018 #ifdef _WIN32 00019 00020 static LARGE_INTEGER freq; 00021 00022 void gettime(TIME_T* time) 00023 { 00024 QueryPerformanceCounter(time); 00025 } 00026 00027 int64 timediff(TIME_T* start, TIME_T* end) 00028 { 00029 return (int64)((end->QuadPart - start->QuadPart)); 00030 } 00031 00032 int64 timenorm(int64 cur_time) 00033 { 00034 static int first = 1; 00035 00036 if(first) 00037 { 00038 QueryPerformanceFrequency(&freq); 00039 first = 0; 00040 } 00041 00042 return (int64)(cur_time * 1000 /(freq.QuadPart)); 00043 } 00044 00045 #else 00046 00047 static struct timezone tz; 00048 00049 void gettime(TIME_T* time) 00050 { 00051 gettimeofday(time, &tz); 00052 } 00053 00054 int64 timediff(TIME_T* start, TIME_T* end) 00055 { 00056 int t1, t2; 00057 00058 t1 = end->tv_sec - start->tv_sec; 00059 t2 = end->tv_usec - start->tv_usec; 00060 return (int64) t2 + (int64) t1 * (int64) 1000000; 00061 } 00062 00063 int64 timenorm(int64 cur_time) 00064 { 00065 return (int64)(cur_time / (int64) 1000); 00066 } 00067 #endif