absence_thelab
annotate src/common/timing.cpp @ 1:4d5933c261c3
todo and .hgignore
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 23 Oct 2014 02:18:43 +0300 |
parents | |
children |
rev | line source |
---|---|
nuclear@0 | 1 #include "timing.h" |
nuclear@0 | 2 |
nuclear@0 | 3 Timer::Timer() { |
nuclear@0 | 4 QueryPerformanceFrequency(&freq); |
nuclear@0 | 5 PauseTime.QuadPart = 0; |
nuclear@0 | 6 paused = false; |
nuclear@0 | 7 } |
nuclear@0 | 8 |
nuclear@0 | 9 void Timer::Start() { |
nuclear@0 | 10 PauseTime.QuadPart = 0; |
nuclear@0 | 11 QueryPerformanceCounter(&start); |
nuclear@0 | 12 } |
nuclear@0 | 13 |
nuclear@0 | 14 void Timer::Stop() { |
nuclear@0 | 15 QueryPerformanceCounter(&LastStop); |
nuclear@0 | 16 } |
nuclear@0 | 17 |
nuclear@0 | 18 void Timer::Resume() { |
nuclear@0 | 19 LARGE_INTEGER resume; |
nuclear@0 | 20 |
nuclear@0 | 21 QueryPerformanceCounter(&resume); |
nuclear@0 | 22 |
nuclear@0 | 23 PauseTime.QuadPart += resume.QuadPart - LastStop.QuadPart; |
nuclear@0 | 24 } |
nuclear@0 | 25 |
nuclear@0 | 26 |
nuclear@0 | 27 unsigned long Timer::GetTicks() const { |
nuclear@0 | 28 LARGE_INTEGER ticks; |
nuclear@0 | 29 |
nuclear@0 | 30 QueryPerformanceCounter(&ticks); |
nuclear@0 | 31 return (unsigned long)(ticks.QuadPart - start.QuadPart - PauseTime.QuadPart); |
nuclear@0 | 32 } |
nuclear@0 | 33 |
nuclear@0 | 34 unsigned long Timer::GetSec() const { |
nuclear@0 | 35 LARGE_INTEGER ticks; |
nuclear@0 | 36 |
nuclear@0 | 37 QueryPerformanceCounter(&ticks); |
nuclear@0 | 38 return (unsigned long)((ticks.QuadPart - start.QuadPart - PauseTime.QuadPart)/freq.QuadPart); |
nuclear@0 | 39 } |
nuclear@0 | 40 |
nuclear@0 | 41 unsigned long Timer::GetMilliSec() const { |
nuclear@0 | 42 LARGE_INTEGER ticks; |
nuclear@0 | 43 |
nuclear@0 | 44 QueryPerformanceCounter(&ticks); |
nuclear@0 | 45 return (unsigned long)((ticks.QuadPart - start.QuadPart - PauseTime.QuadPart)/(freq.QuadPart/1000)); |
nuclear@0 | 46 } |