mirror of
https://github.com/LMMS/lmms.git
synced 2026-03-15 04:27:57 -04:00
28 lines
522 B
C++
28 lines
522 B
C++
#include "MicroTimer.h"
|
|
|
|
using namespace std;
|
|
using namespace std::chrono;
|
|
|
|
static_assert(ratio_less_equal<steady_clock::duration::period, micro>::value,
|
|
"MicroTimer: steady_clock doesn't support microsecond resolution");
|
|
|
|
MicroTimer::MicroTimer()
|
|
{
|
|
reset();
|
|
}
|
|
|
|
MicroTimer::~MicroTimer()
|
|
{
|
|
}
|
|
|
|
void MicroTimer::reset()
|
|
{
|
|
begin = steady_clock::now();
|
|
}
|
|
|
|
int MicroTimer::elapsed() const
|
|
{
|
|
auto now = steady_clock::now();
|
|
return std::chrono::duration_cast<std::chrono::duration<int, std::micro>>(now - begin).count();
|
|
}
|