2013-04-18 03:09:55 +00:00
|
|
|
// Copyright 2013 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>
|
|
|
|
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Common/FileUtil.h"
|
2014-07-03 00:19:08 +00:00
|
|
|
#include "Common/StringUtil.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Common/Timer.h"
|
|
|
|
#include "VideoCommon/FPSCounter.h"
|
|
|
|
#include "VideoCommon/VideoConfig.h"
|
2012-10-04 03:41:02 +00:00
|
|
|
|
|
|
|
#define FPS_REFRESH_INTERVAL 1000
|
|
|
|
|
2014-07-13 11:04:25 +00:00
|
|
|
FPSCounter::FPSCounter()
|
2014-07-26 12:37:18 +00:00
|
|
|
: m_fps(0)
|
|
|
|
, m_counter(0)
|
|
|
|
, m_fps_last_counter(0)
|
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
|
|
|
}
|
|
|
|
|
2014-07-13 11:04:25 +00:00
|
|
|
int 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++;
|
|
|
|
return m_fps;
|
2014-07-03 00:19:08 +00:00
|
|
|
}
|