update code
This commit is contained in:
34
include/PrecisionTimer.h
Normal file
34
include/PrecisionTimer.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user