mirror of
https://github.com/NoelFB/blah.git
synced 2025-02-23 14:28:28 +08:00
27 lines
523 B
C++
27 lines
523 B
C++
|
#include <blah/math/stopwatch.h>
|
||
|
#include <chrono>
|
||
|
|
||
|
using namespace std::chrono;
|
||
|
using namespace Blah;
|
||
|
|
||
|
Stopwatch::Stopwatch()
|
||
|
{
|
||
|
reset();
|
||
|
}
|
||
|
|
||
|
void Stopwatch::reset()
|
||
|
{
|
||
|
start_time = std::chrono::duration_cast<std::chrono::microseconds>(system_clock::now().time_since_epoch()).count();
|
||
|
}
|
||
|
|
||
|
uint64_t Stopwatch::milliseconds()
|
||
|
{
|
||
|
return microseconds() / 1000;
|
||
|
}
|
||
|
|
||
|
|
||
|
uint64_t Stopwatch::microseconds()
|
||
|
{
|
||
|
return std::chrono::duration_cast<std::chrono::microseconds>(system_clock::now().time_since_epoch()).count() - start_time;
|
||
|
}
|