You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
619 B
C++
29 lines
619 B
C++
#pragma once
|
|
#ifndef _TIMER_H_
|
|
#define _TIMER_H_
|
|
#include <chrono>
|
|
class Timer
|
|
{
|
|
public:
|
|
using fmilliseconds = std::chrono::duration<double, std::milli>;
|
|
void start()
|
|
{
|
|
t1 = std::chrono::steady_clock::now();
|
|
}
|
|
void stop()
|
|
{
|
|
t2 = std::chrono::steady_clock::now();
|
|
}
|
|
std::chrono::steady_clock::duration::rep difference()
|
|
{
|
|
return (t2 - t1).count();
|
|
}
|
|
double diff_in_ms()
|
|
{
|
|
return std::chrono::duration_cast<fmilliseconds>(t2 - t1).count();
|
|
}
|
|
private:
|
|
std::chrono::time_point<std::chrono::steady_clock> t1, t2;
|
|
};
|
|
#endif // _TIMER_H_
|