summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/FPSCounter.cpp
diff options
context:
space:
mode:
authorJules Blok <jules.blok@gmail.com>2015-06-10 00:00:12 +0200
committerJules Blok <jules.blok@gmail.com>2015-06-10 00:00:12 +0200
commit7dfced21a2e5aac7195e0e1ad76468e30306766b (patch)
treebd671b639d3d911460b767caabad8fc8a759a6bf /Source/Core/VideoCommon/FPSCounter.cpp
parentc25be031fc1031d795157d8344b87b7841145197 (diff)
parent7b0a65e295c784f9d573f2ef52d4e2a7b9bb2889 (diff)
Merge branch 'master' into stable
Diffstat (limited to 'Source/Core/VideoCommon/FPSCounter.cpp')
-rw-r--r--Source/Core/VideoCommon/FPSCounter.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/FPSCounter.cpp b/Source/Core/VideoCommon/FPSCounter.cpp
new file mode 100644
index 0000000000..54817a7c0e
--- /dev/null
+++ b/Source/Core/VideoCommon/FPSCounter.cpp
@@ -0,0 +1,50 @@
+// Copyright 2012 Dolphin Emulator Project
+// Licensed under GPLv2+
+// Refer to the license.txt file included.
+
+#include <fstream>
+
+#include "Common/FileUtil.h"
+#include "Common/StringUtil.h"
+#include "Common/Timer.h"
+#include "VideoCommon/FPSCounter.h"
+#include "VideoCommon/VideoConfig.h"
+
+#define FPS_REFRESH_INTERVAL 1000
+
+FPSCounter::FPSCounter()
+ : m_fps(0)
+ , m_counter(0)
+ , m_fps_last_counter(0)
+{
+ m_update_time.Update();
+ m_render_time.Update();
+}
+
+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;
+}
+
+int 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();
+ }
+
+ if (g_ActiveConfig.bLogRenderTimeToFile)
+ {
+ LogRenderTimeToFile(m_render_time.GetTimeDifference());
+ m_render_time.Update();
+ }
+
+ m_counter++;
+ return m_fps;
+}