#include <Windows.h> class CTimer { public: CTimer() { QueryPerformanceFrequency(&m_Frequency); Start(); } void Start() { QueryPerformanceCounter(&m_StartCount); } double End() { LARGE_INTEGER CurrentCount; QueryPerformanceCounter(&CurrentCount); return double(CurrentCount.LowPart - m_StartCount.LowPart) / (double)m_Frequency.LowPart; } private: LARGE_INTEGER m_Frequency; LARGE_INTEGER m_StartCount; };
要使用的時候就
CTimer one; XXXXXX(程式區塊) std::cout << one.End() << std::endl;
我忘了是從哪裡補來的就是...XD
0 意見:
張貼留言