| 27 | } |
| 28 | |
| 29 | double GetSystemTimer() |
| 30 | { |
| 31 | if( !timerInitialized ) |
| 32 | { |
| 33 | // We need to know how often the clock is updated |
| 34 | __int64 tps; |
| 35 | if( !QueryPerformanceFrequency((LARGE_INTEGER *)&tps) ) |
| 36 | usePerformance = false; |
| 37 | else |
| 38 | { |
| 39 | usePerformance = true; |
| 40 | ticksPerSecond = (double)tps; |
| 41 | |
| 42 | __int64 ticks; |
| 43 | QueryPerformanceCounter((LARGE_INTEGER *)&ticks); |
| 44 | performanceBase = (double)ticks/ticksPerSecond; |
| 45 | } |
| 46 | |
| 47 | timerInitialized = true; |
| 48 | } |
| 49 | |
| 50 | if( usePerformance ) |
| 51 | { |
| 52 | __int64 ticks; |
| 53 | QueryPerformanceCounter((LARGE_INTEGER *)&ticks); |
| 54 | |
| 55 | double t = (double)ticks/ticksPerSecond - performanceBase; |
| 56 | |
| 57 | // We need to calibrate the performance timer as it is known to jump from time to time |
| 58 | double t2 = (double)timeGetTime()/1000.0; |
| 59 | if( fabs(t-t2) > 0.1 ) |
| 60 | { |
| 61 | performanceBase += t - t2; |
| 62 | t = t2; |
| 63 | } |
| 64 | |
| 65 | return t; |
| 66 | } |
| 67 | else |
| 68 | return (double)timeGetTime()/1000.0; |
| 69 | |
| 70 | // return double(asINT64(GetCPUTime()))/10000000; |
| 71 | } |
| 72 | |
| 73 | #else |
| 74 | // Linux version |
no test coverage detected