2012-03-24 22:39:19 +00:00
|
|
|
#pragma once
|
|
|
|
|
2023-08-02 21:52:46 +00:00
|
|
|
#include <cstdint>
|
|
|
|
|
2012-03-24 22:39:19 +00:00
|
|
|
// Seconds.
|
|
|
|
double time_now_d();
|
|
|
|
|
2023-08-02 21:52:46 +00:00
|
|
|
// Raw time in nanoseconds.
|
|
|
|
// The only intended use is to match the timings from VK_GOOGLE_display_timing.
|
|
|
|
uint64_t time_now_raw();
|
|
|
|
|
2012-03-31 09:16:13 +00:00
|
|
|
// Sleep. Does not necessarily have millisecond granularity, especially on Windows.
|
2012-03-24 22:39:19 +00:00
|
|
|
void sleep_ms(int ms);
|
2020-10-05 18:58:33 +00:00
|
|
|
|
|
|
|
void GetTimeFormatted(char formattedTime[13]);
|
2022-04-08 09:55:49 +00:00
|
|
|
|
|
|
|
// Rust-style Instant for clear and easy timing.
|
|
|
|
class Instant {
|
|
|
|
public:
|
|
|
|
static Instant Now() {
|
|
|
|
return Instant(time_now_d());
|
|
|
|
}
|
|
|
|
double Elapsed() const {
|
|
|
|
return time_now_d() - instantTime_;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
explicit Instant(double initTime) : instantTime_(initTime) {}
|
|
|
|
double instantTime_;
|
|
|
|
};
|