diff options
author | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2017-02-20 22:56:58 +0100 |
---|---|---|
committer | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2017-02-27 02:22:03 +0100 |
commit | b285c2a4ed29a126b5bcfe46e2784bd1870bdf82 (patch) | |
tree | a671ac87427fb63a64f51be260928cb39b8d3737 /src/core/perf_stats.cpp | |
parent | Qt: Add tooltips to status bar displays (diff) | |
download | yuzu-b285c2a4ed29a126b5bcfe46e2784bd1870bdf82.tar yuzu-b285c2a4ed29a126b5bcfe46e2784bd1870bdf82.tar.gz yuzu-b285c2a4ed29a126b5bcfe46e2784bd1870bdf82.tar.bz2 yuzu-b285c2a4ed29a126b5bcfe46e2784bd1870bdf82.tar.lz yuzu-b285c2a4ed29a126b5bcfe46e2784bd1870bdf82.tar.xz yuzu-b285c2a4ed29a126b5bcfe46e2784bd1870bdf82.tar.zst yuzu-b285c2a4ed29a126b5bcfe46e2784bd1870bdf82.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/perf_stats.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/core/perf_stats.cpp b/src/core/perf_stats.cpp index 8d9e521a3..06bc788bd 100644 --- a/src/core/perf_stats.cpp +++ b/src/core/perf_stats.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include <chrono> +#include <mutex> #include "core/hw/gpu.h" #include "core/perf_stats.h" @@ -12,10 +13,14 @@ using std::chrono::duration_cast; 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; @@ -25,10 +30,14 @@ void PerfStats::EndSystemFrame() { } void PerfStats::EndGameFrame() { + std::lock_guard<std::mutex> lock(object_mutex); + game_frames += 1; } PerfStats::Results PerfStats::GetAndResetStats(u64 current_system_time_us) { + std::lock_guard<std::mutex> lock(object_mutex); + auto now = Clock::now(); // Walltime elapsed since stats were reset auto interval = duration_cast<DoubleSecs>(now - reset_point).count(); @@ -54,6 +63,8 @@ PerfStats::Results PerfStats::GetAndResetStats(u64 current_system_time_us) { } 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; } |