2022-12-24 01:52:53 +01:00
|
|
|
// Copyright 2022 Dolphin Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-01-06 23:21:17 +01:00
|
|
|
#include <array>
|
|
|
|
#include <shared_mutex>
|
|
|
|
|
|
|
|
#include "Common/CommonTypes.h"
|
2022-12-24 01:52:53 +01:00
|
|
|
#include "VideoCommon/PerformanceTracker.h"
|
|
|
|
|
2023-01-06 23:21:17 +01:00
|
|
|
namespace Core
|
|
|
|
{
|
|
|
|
class System;
|
|
|
|
}
|
|
|
|
|
2022-12-24 01:52:53 +01:00
|
|
|
class PerformanceMetrics
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PerformanceMetrics() = default;
|
|
|
|
~PerformanceMetrics() = default;
|
|
|
|
|
|
|
|
PerformanceMetrics(const PerformanceMetrics&) = delete;
|
|
|
|
PerformanceMetrics& operator=(const PerformanceMetrics&) = delete;
|
|
|
|
PerformanceMetrics(PerformanceMetrics&&) = delete;
|
|
|
|
PerformanceMetrics& operator=(PerformanceMetrics&&) = delete;
|
|
|
|
|
2022-12-24 02:13:01 +01:00
|
|
|
// Count Functions
|
2022-12-24 01:52:53 +01:00
|
|
|
void Reset();
|
|
|
|
void CountFrame();
|
|
|
|
void CountVBlank();
|
|
|
|
|
2023-01-06 23:21:17 +01:00
|
|
|
void CountThrottleSleep(DT sleep);
|
|
|
|
void CountPerformanceMarker(Core::System& system, s64 cyclesLate);
|
|
|
|
|
2022-12-24 02:13:01 +01:00
|
|
|
// Getter Functions
|
2022-12-24 01:52:53 +01:00
|
|
|
double GetFPS() const;
|
|
|
|
double GetVPS() const;
|
|
|
|
double GetSpeed() const;
|
2023-01-06 23:21:17 +01:00
|
|
|
double GetMaxSpeed() const;
|
2022-12-24 01:52:53 +01:00
|
|
|
|
|
|
|
double GetLastSpeedDenominator() const;
|
|
|
|
|
2022-12-24 02:13:01 +01:00
|
|
|
// ImGui Functions
|
2023-01-06 23:21:17 +01:00
|
|
|
void DrawImGuiStats(const float backbuffer_scale);
|
2022-12-24 01:52:53 +01:00
|
|
|
|
2022-12-24 02:13:01 +01:00
|
|
|
private:
|
2022-12-24 01:52:53 +01:00
|
|
|
PerformanceTracker m_fps_counter{"render_times.txt"};
|
|
|
|
PerformanceTracker m_vps_counter{"vblank_times.txt"};
|
2023-01-29 19:33:48 +01:00
|
|
|
PerformanceTracker m_speed_counter{std::nullopt, 1000000};
|
2023-01-06 23:21:17 +01:00
|
|
|
|
|
|
|
double m_graph_max_time = 0.0;
|
|
|
|
|
|
|
|
mutable std::shared_mutex m_time_lock;
|
|
|
|
|
|
|
|
u8 m_time_index = 0;
|
2023-02-16 04:18:39 +01:00
|
|
|
std::array<TimePoint, 256> m_real_times{};
|
|
|
|
std::array<TimePoint, 256> m_cpu_times{};
|
|
|
|
DT m_time_sleeping{};
|
2022-12-24 01:52:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
extern PerformanceMetrics g_perf_metrics;
|