| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <atomic> |
| 7 |
#include <deque> |
| 8 |
|
| 9 |
#include "Common/CommonTypes.h" |
| 10 |
#include "Common/HookableEvent.h" |
| 11 |
#include "VideoCommon/PerformanceTracker.h" |
| 12 |
|
| 13 |
namespace Core |
| 14 |
{ |
| 15 |
class System; |
| 16 |
} |
| 17 |
|
| 18 |
class PerformanceMetrics |
| 19 |
{ |
| 20 |
public: |
| 21 |
PerformanceMetrics(); |
| 22 |
~PerformanceMetrics() = default; |
| 23 |
|
| 24 |
PerformanceMetrics(const PerformanceMetrics&) = delete; |
| 25 |
PerformanceMetrics& operator=(const PerformanceMetrics&) = delete; |
| 26 |
PerformanceMetrics(PerformanceMetrics&&) = delete; |
| 27 |
PerformanceMetrics& operator=(PerformanceMetrics&&) = delete; |
| 28 |
|
| 29 |
void Reset(); |
| 30 |
|
| 31 |
void CountFrame(); |
| 32 |
void CountVBlank(); |
| 33 |
|
| 34 |
|
| 35 |
void CountThrottleSleep(DT sleep); |
| 36 |
void AdjustClockSpeed(s64 ticks, u32 new_ppc_clock, u32 old_ppc_clock); |
| 37 |
void CountPerformanceMarker(s64 ticks, u32 ticks_per_second); |
| 38 |
|
| 39 |
|
| 40 |
double GetFPS() const; |
| 41 |
double GetVPS() const; |
| 42 |
double GetSpeed() const; |
| 43 |
double GetMaxSpeed() const; |
| 44 |
u32 GetEFBWidth() const; |
| 45 |
u32 GetEFBHeight() const; |
| 46 |
|
| 47 |
void SetLatestFramePresentationOffset(DT offset); |
| 48 |
|
| 49 |
|
| 50 |
void DrawImGuiStats(const float backbuffer_scale); |
| 51 |
|
| 52 |
private: |
| 53 |
PerformanceTracker m_fps_counter{"render_times.txt"}; |
| 54 |
PerformanceTracker m_vps_counter{"vblank_times.txt"}; |
| 55 |
|
| 56 |
double m_graph_max_time = 0.0; |
| 57 |
|
| 58 |
std::atomic<double> m_speed{}; |
| 59 |
std::atomic<double> m_max_speed{}; |
| 60 |
|
| 61 |
std::atomic<DT> m_frame_presentation_offset{}; |
| 62 |
|
| 63 |
struct PerfSample |
| 64 |
{ |
| 65 |
TimePoint clock_time; |
| 66 |
TimePoint work_time; |
| 67 |
s64 core_ticks; |
| 68 |
}; |
| 69 |
|
| 70 |
std::deque<PerfSample> m_samples; |
| 71 |
DT m_time_sleeping{}; |
| 72 |
|
| 73 |
Common::EventHook m_state_change_hook; |
| 74 |
}; |