Create a gist now

Instantly share code, notes, and snippets.

#include <chrono>
class WinTimer {
public:
// create and start timer
WinTimer() { reset(); }
// return ticks since timer creation or last reset
auto ticks() const
{
return (clock::now() - mTimeStart).count();
}
void reset() { mTimeStart = clock::now(); }
static auto ticksPerSecond()
{
double den = clock::duration::period::den;
return den / clock::duration::period::num;
}
private:
using clock = std::chrono::high_resolution_clock;
clock::time_point mTimeStart;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment