Commit ed3b071a authored by Libretro-Admin's avatar Libretro-Admin
Browse files

Remove perf_stats

parent e166bc11
Pipeline #17371 failed with stage
in 3 minutes and 15 seconds
......@@ -408,8 +408,6 @@ add_library(core STATIC
mmio.h
movie.cpp
movie.h
perf_stats.cpp
perf_stats.h
settings.cpp
settings.h
tracer/citrace.h
......
......@@ -150,10 +150,6 @@ void System::PrepareReschedule() {
reschedule_pending = true;
}
PerfStats::Results System::GetAndResetPerfStats() {
return perf_stats.GetAndResetStats(CoreTiming::GetGlobalTimeUs());
}
void System::Reschedule() {
if (!reschedule_pending) {
return;
......@@ -201,10 +197,6 @@ System::ResultStatus System::Init(EmuWindow& emu_window, u32 system_mode) {
LOG_DEBUG(Core, "Initialized OK");
// Reset counters and set time origin to current frame
GetAndResetPerfStats();
perf_stats.BeginSystemFrame();
return ResultStatus::Success;
}
......@@ -221,9 +213,6 @@ void System::RegisterSoftwareKeyboard(std::shared_ptr<Frontend::SoftwareKeyboard
}
void System::Shutdown() {
// Log last frame performance stats
auto perf_results = GetAndResetPerfStats();
// Shutdown emulation session
GDBStub::Shutdown();
VideoCore::Shutdown();
......
......@@ -11,7 +11,6 @@
#include "core/hle/shared_page.h"
#include "core/loader/loader.h"
#include "core/memory.h"
#include "core/perf_stats.h"
class EmuWindow;
class ARM_Interface;
......@@ -149,8 +148,6 @@ public:
*/
const Service::SM::ServiceManager& ServiceManager() const;
PerfStats perf_stats;
void SetStatus(ResultStatus new_status, const char* details = nullptr) {
status = new_status;
if (details) {
......
......@@ -286,10 +286,6 @@ ResultCode SetBufferSwap(u32 screen_id, const FrameBufferInfo& info) {
if (Pica::g_debug_context)
Pica::g_debug_context->OnEvent(Pica::DebugContext::Event::BufferSwapped, nullptr);
if (screen_id == 0) {
Core::System::GetInstance().perf_stats.EndGameFrame();
}
return RESULT_SUCCESS;
}
......
......@@ -219,8 +219,7 @@ void Module::UpdateGyroscopeCallback(u64 userdata, s64 cycles_late) {
Math::Vec3<float> gyro;
std::tie(std::ignore, gyro) = motion_device->GetStatus();
double stretch = Core::System::GetInstance().perf_stats.GetLastFrameTimeScale();
gyro *= gyroscope_coef * static_cast<float>(stretch);
gyro *= gyroscope_coef * 1.00;
gyroscope_entry.x = static_cast<s16>(gyro.x);
gyroscope_entry.y = static_cast<s16>(gyro.y);
gyroscope_entry.z = static_cast<s16>(gyro.z);
......
// Copyright 2017 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <algorithm>
#include <chrono>
#include <mutex>
#include <thread>
#include "core/hw/gpu.h"
#include "core/perf_stats.h"
#include "core/settings.h"
using namespace std::chrono_literals;
using DoubleSecs = std::chrono::duration<double, std::chrono::seconds::period>;
using std::chrono::duration_cast;
using std::chrono::microseconds;
namespace Core {
void PerfStats::BeginSystemFrame() {
std::lock_guard<std::mutex> lock(object_mutex);
frame_begin = Clock::now();
}
void PerfStats::EndSystemFrame() {
std::lock_guard<std::mutex> lock(object_mutex);
auto frame_end = Clock::now();
accumulated_frametime += frame_end - frame_begin;
system_frames += 1;
previous_frame_length = frame_end - previous_frame_end;
previous_frame_end = frame_end;
}
void PerfStats::EndGameFrame() {
std::lock_guard<std::mutex> lock(object_mutex);
game_frames += 1;
}
PerfStats::Results PerfStats::GetAndResetStats(microseconds current_system_time_us) {
std::lock_guard<std::mutex> lock(object_mutex);
const auto now = Clock::now();
// Walltime elapsed since stats were reset
const auto interval = duration_cast<DoubleSecs>(now - reset_point).count();
const auto system_us_per_second = (current_system_time_us - reset_point_system_us) / interval;
Results results{};
results.system_fps = static_cast<double>(system_frames) / interval;
results.game_fps = static_cast<double>(game_frames) / interval;
results.frametime = duration_cast<DoubleSecs>(accumulated_frametime).count() /
static_cast<double>(system_frames);
results.emulation_speed = system_us_per_second.count() / 1'000'000.0;
// Reset counters
reset_point = now;
reset_point_system_us = current_system_time_us;
accumulated_frametime = Clock::duration::zero();
system_frames = 0;
game_frames = 0;
return results;
}
double PerfStats::GetLastFrameTimeScale() {
std::lock_guard<std::mutex> lock(object_mutex);
constexpr double FRAME_LENGTH = 1.0 / GPU::SCREEN_REFRESH_RATE;
return duration_cast<DoubleSecs>(previous_frame_length).count() / FRAME_LENGTH;
}
} // namespace Core
// Copyright 2017 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <chrono>
#include <mutex>
#include "common/common_types.h"
namespace Core {
/**
* Class to manage and query performance/timing statistics. All public functions of this class are
* thread-safe unless stated otherwise.
*/
class PerfStats {
public:
using Clock = std::chrono::high_resolution_clock;
struct Results {
/// System FPS (LCD VBlanks) in Hz
double system_fps;
/// Game FPS (GSP frame submissions) in Hz
double game_fps;
/// Walltime per system frame, in seconds, excluding any waits
double frametime;
/// Ratio of walltime / emulated time elapsed
double emulation_speed;
};
void BeginSystemFrame();
void EndSystemFrame();
void EndGameFrame();
Results GetAndResetStats(std::chrono::microseconds current_system_time_us);
/**
* Gets the ratio between walltime and the emulated time of the previous system frame. This is
* useful for scaling inputs or outputs moving between the two time domains.
*/
double GetLastFrameTimeScale();
private:
std::mutex object_mutex;
/// Point when the cumulative counters were reset
Clock::time_point reset_point = Clock::now();
/// System time when the cumulative counters were reset
std::chrono::microseconds reset_point_system_us{0};
/// Cumulative duration (excluding v-sync/frame-limiting) of frames since last reset
Clock::duration accumulated_frametime = Clock::duration::zero();
/// Cumulative number of system frames (LCD VBlanks) presented since last reset
u32 system_frames = 0;
/// Cumulative number of game frames (GSP frame submissions) since last reset
u32 game_frames = 0;
/// Point when the previous system frame ended
Clock::time_point previous_frame_end = reset_point;
/// Point when the current system frame began
Clock::time_point frame_begin = reset_point;
/// Total visible duration (including frame-limiting, etc.) of the previous system frame
Clock::duration previous_frame_length = Clock::duration::zero();
};
} // namespace Core
......@@ -142,14 +142,10 @@ void RendererOpenGL::SwapBuffers() {
DrawScreens();
Core::System::GetInstance().perf_stats.EndSystemFrame();
// Swap buffers
render_window.PollEvents();
render_window.SwapBuffers();
Core::System::GetInstance().perf_stats.BeginSystemFrame();
prev_state.Apply();
RefreshRasterizerSetting();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment