dungeon_crawler

view prototype/src/timer.cc @ 80:a373b36ffc17

better
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 27 Oct 2012 01:59:39 +0300
parents 862461b686f4
children
line source
1 #ifndef _MSC_VER
2 #include <chrono>
3 #include "timer.h"
5 using namespace std::chrono;
7 static bool timer_initialized;
8 static time_point<steady_clock> start_time;
10 unsigned long get_time_msec(void)
11 {
12 if(!timer_initialized) {
13 start_time = steady_clock::now();
14 timer_initialized = true;
15 }
17 auto dur = steady_clock::now() - start_time;
18 return duration_cast<milliseconds>(dur).count();
19 }
20 #else
21 #include <Windows.h>
23 unsigned long get_time_msec(void)
24 {
25 return GetTickCount();
26 }
27 #endif