Windows下 C++测量时间的函数 精度为可以到100us级别
class RecordTimer { public: RecordTimer(); ~RecordTimer(); void start(); void end(); double getTick(); private: LARGE_INTEGER m_frequency; LARGE_INTEGER m_startTime; LARGE_INTEGER m_endTime; }; RecordTimer::RecordTimer() { QueryPerformanceFrequency(&m_frequency); } RecordTimer::~RecordTimer() { } void RecordTimer::start() { QueryPerformanceCounter(&m_startTime); } void RecordTimer::end() { QueryPerformanceCounter(&m_endTime); } double RecordTimer::getTick() { return (double)(m_endTime.QuadPart - m_startTime.QuadPart)*1.0 / m_frequency.QuadPart * 1000; }