2013-04-17 21:09:55 -06:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2012-10-03 21:41:02 -06:00
|
|
|
|
2014-07-02 18:19:08 -06:00
|
|
|
#include <fstream>
|
|
|
|
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "Common/FileUtil.h"
|
2014-07-02 18:19:08 -06:00
|
|
|
#include "Common/StringUtil.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "Common/Timer.h"
|
|
|
|
#include "VideoCommon/FPSCounter.h"
|
|
|
|
#include "VideoCommon/VideoConfig.h"
|
2012-10-03 21:41:02 -06:00
|
|
|
|
|
|
|
#define FPS_REFRESH_INTERVAL 1000
|
|
|
|
|
2014-07-13 05:04:25 -06:00
|
|
|
FPSCounter::FPSCounter()
|
2014-07-26 06:37:18 -06:00
|
|
|
: m_fps(0)
|
|
|
|
, m_counter(0)
|
|
|
|
, m_fps_last_counter(0)
|
2012-10-03 21:41:02 -06:00
|
|
|
{
|
2014-07-13 05:04:25 -06:00
|
|
|
m_update_time.Update();
|
|
|
|
m_render_time.Update();
|
2012-10-03 21:41:02 -06:00
|
|
|
}
|
|
|
|
|
2014-07-13 05:04:25 -06:00
|
|
|
void FPSCounter::LogRenderTimeToFile(u64 val)
|
2012-10-03 21:41:02 -06:00
|
|
|
{
|
2014-07-13 05:04:25 -06:00
|
|
|
if (!m_bench_file.is_open())
|
|
|
|
m_bench_file.open(File::GetUserPath(D_LOGS_IDX) + "render_time.txt");
|
2012-10-03 21:41:02 -06:00
|
|
|
|
2014-07-13 05:04:25 -06:00
|
|
|
m_bench_file << val << std::endl;
|
2012-10-03 21:41:02 -06:00
|
|
|
}
|
|
|
|
|
2014-07-13 05:04:25 -06:00
|
|
|
int FPSCounter::Update()
|
2012-10-03 21:41:02 -06:00
|
|
|
{
|
2014-07-13 05:04:25 -06:00
|
|
|
if (m_update_time.GetTimeDifference() >= FPS_REFRESH_INTERVAL)
|
2012-10-03 21:41:02 -06:00
|
|
|
{
|
2014-07-13 05:04:25 -06: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-03 21:41:02 -06:00
|
|
|
}
|
|
|
|
|
2014-07-09 09:03:17 -06:00
|
|
|
if (g_ActiveConfig.bLogRenderTimeToFile)
|
|
|
|
{
|
2014-07-13 05:04:25 -06:00
|
|
|
LogRenderTimeToFile(m_render_time.GetTimeDifference());
|
|
|
|
m_render_time.Update();
|
2014-07-09 09:03:17 -06:00
|
|
|
}
|
|
|
|
|
2014-07-13 05:04:25 -06:00
|
|
|
m_counter++;
|
|
|
|
return m_fps;
|
2014-07-02 18:19:08 -06:00
|
|
|
}
|