Files
QTradeProgram/include/PrecisionTimer.h

35 lines
570 B
C
Raw Normal View History

2025-08-15 15:57:31 +08:00
#pragma once
#include <chrono>
class CPrecisionTimer
{
public:
using Clock = std::chrono::high_resolution_clock;
using TimePoint = Clock::time_point;
using Nanoseconds = std::chrono::nanoseconds;
void start() {
m_start = Clock::now();
}
Nanoseconds stop() {
return Clock::now() - m_start;
}
static double toSeconds(Nanoseconds ns) {
return ns.count() / 1e9;
}
static double toMilliseconds(Nanoseconds ns) {
return ns.count() / 1e6;
}
static double toMicrosecond(Nanoseconds ns) {
return ns.count() / 1e3;
}
private:
TimePoint m_start;
};