Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 9th, 2012  |  syntax: C++  |  size: 0.36 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #pragma once
  2. #include <MMSystem.h>
  3.  
  4. #pragma comment(lib, "winmm.lib")
  5.  
  6. class SimpleTimer
  7. {
  8.         UINT startcycles;
  9.  
  10. public:
  11.  
  12.         UINT m_overhead;
  13.  
  14.         SimpleTimer(void)
  15.         {
  16.                 m_overhead=0;
  17.                 Start();
  18.                 m_overhead = Stop();
  19.         }
  20.  
  21.         void Start()
  22.         {
  23.                 startcycles = timeGetTime();
  24.         }
  25.         UINT Stop()
  26.         {
  27.                 return timeGetTime()-startcycles-m_overhead;
  28.         }
  29. };