Clock Class Referencemillisecond timer for debug printing More...
Detailed Descriptionmillisecond timer for debug printingFile ......... Clock.h Published .... 2005-06-14 Author ....... grymse@alhem.net
Definition at line 37 of file Clock.h. Constructor & Destructor Documentation
File ......... Clock.cpp Published .... 2005-06-14 Author ....... grymse@alhem.net Definition at line 30 of file Clock.cpp. References m_tv, m_tv0, m_tz, and m_tz0. 00031 { 00032 #ifdef _WIN32 00033 ::GetLocalTime(&m_time); 00034 ::GetLocalTime(&m_time0); 00035 #else 00036 gettimeofday(&m_tv, &m_tz); 00037 gettimeofday(&m_tv0, &m_tz0); 00038 #endif 00039 }
Member Function Documentation
Definition at line 47 of file Clock.cpp. References m_tv, m_tv0, and Reset(). 00048 { 00049 #ifdef _WIN32 00050 SYSTEMTIME time; 00051 SYSTEMTIME time0; 00052 ::GetLocalTime(&time); 00053 ::GetLocalTime(&time0); 00054 time.wSecond -= m_time.wSecond; 00055 if (time.wSecond < 0) 00056 time.wSecond += 60; 00057 { 00058 time_t t = time.wSecond * 1000 + time.wMilliseconds - m_time.wMilliseconds; 00059 time_t s = t / 1000; 00060 time_t m = t % 1000; 00061 if (!str.size()) 00062 printf("Time: %d.%03d", s, m); 00063 else 00064 printf("Time %s: %d.%03d", str.c_str(), s, m); 00065 } 00066 time0.wSecond -= m_time0.wSecond; 00067 if (time0.wSecond < 0) 00068 time0.wSecond += 60; 00069 { 00070 time_t t = time0.wSecond * 1000 + time0.wMilliseconds - m_time0.wMilliseconds; 00071 time_t s = t / 1000; 00072 time_t m = t % 1000; 00073 if (!str.size()) 00074 printf("Time: %d.%03d", s, m); 00075 else 00076 printf("Time %s: %d.%03d", str.c_str(), s, m); 00077 } 00078 #else 00079 struct timeval tv; 00080 struct timezone tz; 00081 struct timeval tv0; 00082 struct timezone tz0; 00083 gettimeofday(&tv, &tz); 00084 gettimeofday(&tv0, &tz0); 00085 tv.tv_sec -= m_tv.tv_sec; 00086 { 00087 time_t t = tv.tv_sec * 1000000 + tv.tv_usec - m_tv.tv_usec; 00088 time_t s = t / 1000000; 00089 time_t u = t % 1000000; 00090 if (!str.size()) 00091 printf("Time: %d.%06d", s, u); 00092 else 00093 printf("Time %s: %d.%06d", str.c_str(), s, u); 00094 } 00095 tv0.tv_sec -= m_tv0.tv_sec; 00096 { 00097 time_t t = tv0.tv_sec * 1000000 + tv0.tv_usec - m_tv0.tv_usec; 00098 time_t s = t / 1000000; 00099 time_t u = t % 1000000; 00100 if (!str.size()) 00101 printf(" / %d.%06d", s, u); 00102 else 00103 printf(" / %d.%06d", s, u); 00104 } 00105 printf("\n"); 00106 #endif 00107 Reset(); 00108 }
Member Data Documentation
The documentation for this class was generated from the following files: |