• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

src/util/src/Timer.cpp

Go to the documentation of this file.
00001 #include "../pch.h"
00002 
00003 Timer::Timer(){
00004 }
00005 
00006 Timer::~Timer(){
00007         uninit();
00008 }
00009 
00010 double Timer::freq;
00011 
00012 bool Timer::init(void){
00013         long long llfreq;
00014 
00015         if(QueryPerformanceFrequency((LARGE_INTEGER*)&llfreq) == 0)
00016                 return false;
00017 
00018         freq = 1.0 / llfreq;
00019         QueryPerformanceCounter((LARGE_INTEGER*)&start);
00020         count = start;
00021         return true;
00022 }
00023 
00024 void Timer::uninit(void){
00025 }
00026 
00027 double Timer::time(void){
00028         long long llcount;
00029         QueryPerformanceCounter((LARGE_INTEGER*)&llcount);
00030         return (llcount - start) / freq;
00031 }
00032 
00033 float Timer::timef(void){
00034         long long llcount;
00035         QueryPerformanceCounter((LARGE_INTEGER*)&llcount);
00036         return float((llcount - start) / freq);
00037 }
00038 
00039 double Timer::delta(void){
00040         lastcount = count;
00041         QueryPerformanceCounter((LARGE_INTEGER*)&count);
00042         return (count - lastcount) * freq;
00043 }
00044 
00045 float Timer::deltaf(void){
00046         lastcount = count;
00047         QueryPerformanceCounter((LARGE_INTEGER*)&count);
00048         return float((count - lastcount) * freq);
00049 }

Generated on Fri Jun 18 2010 17:48:40 for Cannonball by  doxygen 1.7.0