dolphin/Source/Core/VideoCommon/PerformanceMetrics.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

68 lines
1.5 KiB
C
Raw Permalink Normal View History

2022-12-23 19:52:53 -05:00
// Copyright 2022 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <atomic>
#include <deque>
#include "Common/CommonTypes.h"
2022-12-23 19:52:53 -05:00
#include "VideoCommon/PerformanceTracker.h"
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;
void Reset();
2022-12-23 19:52:53 -05:00
void CountFrame();
void CountVBlank();
// Call from CPU thread.
void CountThrottleSleep(DT sleep);
void AdjustClockSpeed(s64 ticks, u32 new_ppc_clock, u32 old_ppc_clock);
void CountPerformanceMarker(s64 ticks, u32 ticks_per_second);
// Getter Functions. May be called from any thread.
2022-12-23 19:52:53 -05:00
double GetFPS() const;
double GetVPS() const;
double GetSpeed() const;
double GetMaxSpeed() const;
2022-12-23 19:52:53 -05:00
2022-12-23 20:13:01 -05:00
// ImGui Functions
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"};
double m_graph_max_time = 0.0;
std::atomic<double> m_speed{};
std::atomic<double> m_max_speed{};
struct PerfSample
{
TimePoint clock_time;
TimePoint work_time;
s64 core_ticks;
};
std::deque<PerfSample> m_samples;
DT m_time_sleeping{};
2022-12-23 19:52:53 -05:00
};
extern PerformanceMetrics g_perf_metrics;