svvitch
digital signage player
D:/vs_workspace/switch_sf/src/svvitch/PerformanceTimer.h
Go to the documentation of this file.
00001 #pragma once
00002 
00003 #include "Common.h"
00004 
00009 class PerformanceTimer
00010 {
00011 private:
00012     LARGE_INTEGER _freq;
00013     LARGE_INTEGER _start;
00014     LARGE_INTEGER _current;
00015     bool _enabled;
00016 
00017 public:
00018     PerformanceTimer(): _enabled(false) {
00019         ::QueryPerformanceFrequency(&_freq);
00020     }
00021 
00022     virtual ‾PerformanceTimer() {
00023     }
00024 
00025     virtual void start() {
00026         ::QueryPerformanceCounter(&_start);
00027         _current = _start;
00028         _enabled = true;
00029     }
00030 
00031     const DWORD getTime() {
00032         if (_enabled) {
00033             ::QueryPerformanceCounter(&_current);
00034             return (DWORD)((_current.QuadPart - _start.QuadPart) * 1000 / _freq.QuadPart);
00035         }
00036         return 0;
00037     }
00038 
00039     void update() {
00040         _start = _current;
00041     }
00042 };
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines