Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

vuTimer.cpp

Go to the documentation of this file.
00001 #include "vuTimer.h"
00002 #include "vuSimpleTypes.h"
00003 #include <sys/time.h>
00004 
00005 #ifdef __MINGW32__
00006 #include <windows.h>
00007 #warning TODO: find a better solution
00008 int gettimeofday(struct timeval* tp, void* tzp)
00009 {
00010         DWORD t = timeGetTime();
00011         tp->tv_sec = t / 1000;
00012         tp->tv_usec = t % 1000;
00013         return 0;
00014 }
00015 #endif
00016 
00017 unsigned long vuTimer::getMilliSeconds()
00018 {
00019   static struct timeval time;
00020  
00021   gettimeofday(&time, 0);
00022   
00023   return (unsigned long)time.tv_sec*1000 + (unsigned long)time.tv_usec/1000;
00024 }
00025 
00026 double vuTimer::getMilliSecondsAsDouble()
00027 {
00028   static struct timeval time;
00029  
00030   gettimeofday(&time, 0);
00031   
00032   return (double)time.tv_sec*1000 + (double)time.tv_usec/1000.0f;
00033 }
00034 
00035 
00036 vuTimer::vuTimer()
00037 {
00038   start();
00039 }
00040 
00041 void vuTimer::start()
00042 {
00043   m_StartTime = vuTimer::getMilliSeconds();
00044   m_EndTime   = m_StartTime;
00045 }
00046 
00047 void vuTimer::stop()
00048 {
00049   m_EndTime = vuTimer::getMilliSeconds();
00050 }
00051 
00052 unsigned long vuTimer::getInterval()
00053 {
00054   return m_EndTime - m_StartTime;
00055 }
00056 

Generated on Wed Dec 15 21:20:38 2004 for vuVolume by  doxygen 1.3.9.1