jak-project/common/util/Timer.h
water111 a6fa04a83d
[graphics] port generic VU1 to OpenGL (#1221)
* temp

* name the obvious ones

* un-pipelined the fast case in generic vu1

* generic2 dma

* pass2

* first pass at opengl

* many fixes

* fix hud, strip

* windows fix

* final tweaks

* memcard folder

* add missing include
2022-03-06 19:56:43 -05:00

45 lines
743 B
C++

#pragma once
#include <cstdint>
#include <ctime>
#include "common/util/Assert.h"
/*!
* Timer for measuring time elapsed with clock_monotonic
*/
class Timer {
public:
/*!
* Construct and start timer
*/
explicit Timer() { start(); }
#ifdef _WIN32
int clock_gettime_monotonic(struct timespec* tv) const;
#endif
/*!
* Start the timer
*/
void start();
/*!
* Get milliseconds elapsed
*/
double getMs() const { return (double)getNs() / 1.e6; }
double getUs() const { return (double)getNs() / 1.e3; }
/*!
* Get nanoseconds elapsed
*/
int64_t getNs() const;
/*!
* Get seconds elapsed
*/
double getSeconds() const { return (double)getNs() / 1.e9; }
struct timespec _startTime = {};
};