absence_thelab
view 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 |
line source
1 #include "timing.h"
3 Timer::Timer() {
4 QueryPerformanceFrequency(&freq);
5 PauseTime.QuadPart = 0;
6 paused = false;
7 }
9 void Timer::Start() {
10 PauseTime.QuadPart = 0;
11 QueryPerformanceCounter(&start);
12 }
14 void Timer::Stop() {
15 QueryPerformanceCounter(&LastStop);
16 }
18 void Timer::Resume() {
19 LARGE_INTEGER resume;
21 QueryPerformanceCounter(&resume);
23 PauseTime.QuadPart += resume.QuadPart - LastStop.QuadPart;
24 }
27 unsigned long Timer::GetTicks() const {
28 LARGE_INTEGER ticks;
30 QueryPerformanceCounter(&ticks);
31 return (unsigned long)(ticks.QuadPart - start.QuadPart - PauseTime.QuadPart);
32 }
34 unsigned long Timer::GetSec() const {
35 LARGE_INTEGER ticks;
37 QueryPerformanceCounter(&ticks);
38 return (unsigned long)((ticks.QuadPart - start.QuadPart - PauseTime.QuadPart)/freq.QuadPart);
39 }
41 unsigned long Timer::GetMilliSec() const {
42 LARGE_INTEGER ticks;
44 QueryPerformanceCounter(&ticks);
45 return (unsigned long)((ticks.QuadPart - start.QuadPart - PauseTime.QuadPart)/(freq.QuadPart/1000));
46 }