2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2012 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 03:09:55 +00:00
|
|
|
// Refer to the license.txt file included.
|
2012-10-04 03:41:02 +00:00
|
|
|
|
2014-07-03 00:19:08 +00:00
|
|
|
#include <fstream>
|
|
|
|
|
2016-01-17 21:54:31 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Common/FileUtil.h"
|
|
|
|
#include "Common/Timer.h"
|
|
|
|
#include "VideoCommon/FPSCounter.h"
|
|
|
|
#include "VideoCommon/VideoConfig.h"
|
2012-10-04 03:41:02 +00:00
|
|
|
|
2015-09-29 13:49:12 +00:00
|
|
|
static constexpr u64 FPS_REFRESH_INTERVAL = 1000;
|
2012-10-04 03:41:02 +00:00
|
|
|
|
2014-07-13 11:04:25 +00:00
|
|
|
FPSCounter::FPSCounter()
|
2012-10-04 03:41:02 +00:00
|
|
|
{
|
2014-07-13 11:04:25 +00:00
|
|
|
m_update_time.Update();
|
|
|
|
m_render_time.Update();
|
2012-10-04 03:41:02 +00:00
|
|
|
}
|
|
|
|
|
2014-07-13 11:04:25 +00:00
|
|
|
void FPSCounter::LogRenderTimeToFile(u64 val)
|
2012-10-04 03:41:02 +00:00
|
|
|
{
|
2014-07-13 11:04:25 +00:00
|
|
|
if (!m_bench_file.is_open())
|
|
|
|
m_bench_file.open(File::GetUserPath(D_LOGS_IDX) + "render_time.txt");
|
2012-10-04 03:41:02 +00:00
|
|
|
|
2014-07-13 11:04:25 +00:00
|
|
|
m_bench_file << val << std::endl;
|
2012-10-04 03:41:02 +00:00
|
|
|
}
|
|
|
|
|
2015-09-29 13:57:54 +00:00
|
|
|
void FPSCounter::Update()
|
2012-10-04 03:41:02 +00:00
|
|
|
{
|
2014-07-13 11:04:25 +00:00
|
|
|
if (m_update_time.GetTimeDifference() >= FPS_REFRESH_INTERVAL)
|
2012-10-04 03:41:02 +00:00
|
|
|
{
|
2014-07-13 11:04:25 +00:00
|
|
|
m_update_time.Update();
|
|
|
|
m_fps = m_counter - m_fps_last_counter;
|
|
|
|
m_fps_last_counter = m_counter;
|
|
|
|
m_bench_file.flush();
|
2012-10-04 03:41:02 +00:00
|
|
|
}
|
|
|
|
|
2014-07-09 15:03:17 +00:00
|
|
|
if (g_ActiveConfig.bLogRenderTimeToFile)
|
|
|
|
{
|
2014-07-13 11:04:25 +00:00
|
|
|
LogRenderTimeToFile(m_render_time.GetTimeDifference());
|
|
|
|
m_render_time.Update();
|
2014-07-09 15:03:17 +00:00
|
|
|
}
|
|
|
|
|
2014-07-13 11:04:25 +00:00
|
|
|
m_counter++;
|
2014-07-03 00:19:08 +00:00
|
|
|
}
|