2022-12-23 19:52:53 -05:00
|
|
|
// Copyright 2022 Dolphin Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-01-06 17:21:17 -05:00
|
|
|
#include <array>
|
2025-03-04 21:32:31 -06:00
|
|
|
#include <atomic>
|
2023-01-06 17:21:17 -05:00
|
|
|
|
|
|
|
#include "Common/CommonTypes.h"
|
2022-12-23 19:52:53 -05:00
|
|
|
#include "VideoCommon/PerformanceTracker.h"
|
|
|
|
|
2023-01-06 17:21:17 -05:00
|
|
|
namespace Core
|
|
|
|
{
|
|
|
|
class System;
|
|
|
|
}
|
|
|
|
|
2022-12-23 19:52:53 -05: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-23 20:13:01 -05:00
|
|
|
// Count Functions
|
2022-12-23 19:52:53 -05:00
|
|
|
void Reset();
|
|
|
|
void CountFrame();
|
|
|
|
void CountVBlank();
|
|
|
|
|
2023-01-06 17:21:17 -05:00
|
|
|
void CountThrottleSleep(DT sleep);
|
|
|
|
void CountPerformanceMarker(Core::System& system, s64 cyclesLate);
|
|
|
|
|
2022-12-23 20:13:01 -05:00
|
|
|
// Getter Functions
|
2022-12-23 19:52:53 -05:00
|
|
|
double GetFPS() const;
|
|
|
|
double GetVPS() const;
|
|
|
|
double GetSpeed() const;
|
2023-01-06 17:21:17 -05:00
|
|
|
double GetMaxSpeed() const;
|
2022-12-23 19:52:53 -05:00
|
|
|
|
2022-12-23 20:13:01 -05:00
|
|
|
// ImGui Functions
|
2023-01-06 17:21:17 -05:00
|
|
|
void DrawImGuiStats(const float backbuffer_scale);
|
2022-12-23 19:52:53 -05:00
|
|
|
|
2022-12-23 20:13:01 -05:00
|
|
|
private:
|
2022-12-23 19:52:53 -05:00
|
|
|
PerformanceTracker m_fps_counter{"render_times.txt"};
|
|
|
|
PerformanceTracker m_vps_counter{"vblank_times.txt"};
|
2025-03-05 01:36:18 -06:00
|
|
|
PerformanceTracker m_speed_counter{std::nullopt, std::chrono::seconds{1}};
|
2023-01-06 17:21:17 -05:00
|
|
|
|
|
|
|
double m_graph_max_time = 0.0;
|
|
|
|
|
2025-03-04 21:32:31 -06:00
|
|
|
std::atomic<double> m_max_speed{};
|
2023-01-06 17:21:17 -05:00
|
|
|
u8 m_time_index = 0;
|
2023-02-15 19:18:39 -08:00
|
|
|
std::array<TimePoint, 256> m_real_times{};
|
2025-03-04 21:32:31 -06:00
|
|
|
std::array<u64, 256> m_core_ticks{};
|
2023-02-15 19:18:39 -08:00
|
|
|
DT m_time_sleeping{};
|
2022-12-23 19:52:53 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
extern PerformanceMetrics g_perf_metrics;
|