home *** CD-ROM | disk | FTP | other *** search
/ PC to Maximum / PC-na-maximum.bin / CPUSpeed / Timer.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-09  |  534 b   |  27 lines

  1. #include "Timer.h"
  2.  
  3. // The CTimer class was written by Feng Yuan, and was used from his post on www.codeguru.com.  
  4.  
  5. inline unsigned __int64 GetCycleCount(void)
  6. {
  7.     _asm    _emit 0x0F
  8.     _asm    _emit 0x31
  9. }
  10.  
  11.     CTimer::CTimer(void)
  12.     {
  13.         m_overhead = 0;
  14.         Start();
  15.         m_overhead = Stop();
  16.     }
  17.     
  18.     void CTimer::Start(void)
  19.     {
  20.         m_startcycle = GetCycleCount();
  21.     }
  22.  
  23.     unsigned __int64 CTimer::Stop(void)
  24.     {
  25.         return GetCycleCount()-m_startcycle-m_overhead;
  26.     }
  27.