dungeon_crawler
annotate prototype/src/timer.cc @ 66:6a471c87f9ca
- added visual studio project files
- changed some __func__ into __FUNCTION__ to compile on visual studio
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 07 Oct 2012 00:19:48 +0200 |
parents | |
children | 45172d087ebe |
rev | line source |
---|---|
nuclear@38 | 1 #include <chrono> |
nuclear@38 | 2 #include "timer.h" |
nuclear@38 | 3 |
nuclear@38 | 4 using namespace std::chrono; |
nuclear@38 | 5 |
nuclear@38 | 6 static bool timer_initialized; |
nuclear@38 | 7 static time_point<steady_clock> start_time; |
nuclear@38 | 8 |
nuclear@38 | 9 unsigned long get_time_msec(void) |
nuclear@38 | 10 { |
nuclear@38 | 11 if(!timer_initialized) { |
nuclear@38 | 12 start_time = steady_clock::now(); |
nuclear@38 | 13 timer_initialized = true; |
nuclear@38 | 14 } |
nuclear@38 | 15 |
nuclear@38 | 16 auto dur = steady_clock::now() - start_time; |
nuclear@38 | 17 return duration_cast<milliseconds>(dur).count(); |
nuclear@38 | 18 } |