mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Add new TimeSpan class for more accurate timing.
Minimizes the amount of value conversions and performs subtractions in integer space.
This commit is contained in:
1 parent
3e26866f76
commit
fa5ec667ef
3 files changed
+88
-8
No files matched your search
+14
-2
@@ -1,5 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
// Seconds.
|
||||
@@ -30,10 +29,23 @@ public:
|
||||
static Instant Now() {
|
||||
return Instant(time_now_d());
|
||||
}
|
||||
double Elapsed() const {
|
||||
double ElapsedSeconds() const {
|
||||
return time_now_d() - instantTime_;
|
||||
}
|
||||
private:
|
||||
explicit Instant(double initTime) : instantTime_(initTime) {}
|
||||
double instantTime_;
|
||||
};
|
||||
|
||||
// Most accurate timer possible - no extra double conversions. Only for spans.
|
||||
class TimeSpan {
|
||||
public:
|
||||
TimeSpan();
|
||||
double ElapsedSeconds() const;
|
||||
int64_t ElapsedNanos() const;
|
||||
private:
|
||||
uint64_t nativeStart_;
|
||||
#ifndef _WIN32
|
||||
int64_t nsecs_;
|
||||
#endif
|
||||
};
|
||||
Reference in new issue
Block a user