diff options
| author | Anthony <Helios747@users.noreply.github.com> | 2017-07-30 00:42:36 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-07-30 00:42:36 -0700 |
| commit | 5bad2ee4a4129e734ff4f4d861cedc4cd573df55 (patch) | |
| tree | cd3c3ccc6e35417858499449d774670c3983cb13 /Source/Core/VideoCommon/FPSCounter.cpp | |
| parent | 5e6d5493165d1214f513b91eaeb4e162d21fdd3e (diff) | |
| parent | 357c55442f3dbdf6f23d16af5362d1a615cb84c1 (diff) | |
Merge pull request #5832 from stenzek/ubershader-prereq
Ubershader prerequisites
Diffstat (limited to 'Source/Core/VideoCommon/FPSCounter.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/FPSCounter.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/Source/Core/VideoCommon/FPSCounter.cpp b/Source/Core/VideoCommon/FPSCounter.cpp index 2d17d00a41..86b3ab5c85 100644 --- a/Source/Core/VideoCommon/FPSCounter.cpp +++ b/Source/Core/VideoCommon/FPSCounter.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include <fstream> +#include <iomanip> #include "Common/CommonTypes.h" #include "Common/FileUtil.h" @@ -10,12 +11,11 @@ #include "VideoCommon/FPSCounter.h" #include "VideoCommon/VideoConfig.h" -static constexpr u64 FPS_REFRESH_INTERVAL = 1000; +static constexpr u64 FPS_REFRESH_INTERVAL = 250000; FPSCounter::FPSCounter() { - m_update_time.Update(); - m_render_time.Update(); + m_last_time = Common::Timer::GetTimeUs(); } void FPSCounter::LogRenderTimeToFile(u64 val) @@ -23,24 +23,24 @@ void FPSCounter::LogRenderTimeToFile(u64 val) if (!m_bench_file.is_open()) m_bench_file.open(File::GetUserPath(D_LOGS_IDX) + "render_time.txt"); - m_bench_file << val << std::endl; + m_bench_file << std::fixed << std::setprecision(8) << (val / 1000.0) << std::endl; } void FPSCounter::Update() { - if (m_update_time.GetTimeDifference() >= FPS_REFRESH_INTERVAL) - { - m_update_time.Update(); - m_fps = m_counter - m_fps_last_counter; - m_fps_last_counter = m_counter; - m_bench_file.flush(); - } - + u64 time = Common::Timer::GetTimeUs(); + u64 diff = time - m_last_time; if (g_ActiveConfig.bLogRenderTimeToFile) + LogRenderTimeToFile(diff); + + m_frame_counter++; + m_time_since_update += diff; + m_last_time = time; + + if (m_time_since_update >= FPS_REFRESH_INTERVAL) { - LogRenderTimeToFile(m_render_time.GetTimeDifference()); - m_render_time.Update(); + m_fps = m_frame_counter / (m_time_since_update / 1000000.0); + m_frame_counter = 0; + m_time_since_update = 0; } - - m_counter++; } |
