ppsspp/Common/TimeUtil.h
Henrik Rydgård 1dab6e5bef Linux/Mac/iOS: Switch from gettimeofday() to clock_gettime(CLOCK_MONOTONIC)
More appropriate, and adds a raw function that can be used to match up
with  VK_GOOGLE_display_timing.
2023-08-03 00:00:07 +02:00

30 lines
654 B
C++

#pragma once
#include <cstdint>
// Seconds.
double time_now_d();
// Raw time in nanoseconds.
// The only intended use is to match the timings from VK_GOOGLE_display_timing.
uint64_t time_now_raw();
// Sleep. Does not necessarily have millisecond granularity, especially on Windows.
void sleep_ms(int ms);
void GetTimeFormatted(char formattedTime[13]);
// 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_;
};