00001
00002
00003 #pragma once
00004 #ifndef STOPWATCH_H
00005 #define STOPWATCH_H
00006
00007 #ifdef RT_PROFILER
00008
00009 #include <windows.h>
00010
00011 namespace RenderTools {
00012
00013 class Stopwatch {
00014 public:
00015
00016 Stopwatch(){
00017 QueryPerformanceFrequency( (LARGE_INTEGER *)& m_ticksPerSecond );
00018 reset();
00019 }
00020 void reset(){
00021 QueryPerformanceCounter( (LARGE_INTEGER *)& m_t0 );
00022 QueryPerformanceCounter( (LARGE_INTEGER *)& m_t1 );
00023 }
00024 double lapse(){
00025 QueryPerformanceCounter( (LARGE_INTEGER *)& m_t1 );
00026 __int64 ticks = m_t1 - m_t0;
00027 reset();
00028 return( (double)ticks / (double)m_ticksPerSecond );
00029 }
00030
00031 private:
00032 __int64 m_ticksPerSecond;
00033 __int64 m_t0;
00034 __int64 m_t1;
00035 };
00036
00037 };
00038
00039 #endif // RT_PROFILER
00040
00041 #endif