Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

50 lines
1.1 KiB
C++
Raw Permalink Normal View History

// Copyright 2012 Dolphin Emulator Project
2015-05-18 01:08:10 +02:00
// Licensed under GPLv2+
// Refer to the license.txt file included.
2014-07-02 20:19:08 -04:00
#include <fstream>
#include <iomanip>
2014-02-17 05:18:15 -05:00
2016-01-17 16:54:31 -05:00
#include "Common/CommonTypes.h"
2014-07-02 20:19:08 -04:00
#include "Common/FileUtil.h"
#include "Common/Timer.h"
2014-02-17 05:18:15 -05:00
#include "VideoCommon/FPSCounter.h"
#include "VideoCommon/VideoConfig.h"
static constexpr u64 FPS_REFRESH_INTERVAL = 250000;
2014-07-13 13:04:25 +02:00
FPSCounter::FPSCounter()
{
m_last_time = Common::Timer::GetTimeUs();
}
2014-07-13 13:04:25 +02:00
void FPSCounter::LogRenderTimeToFile(u64 val)
{
2014-07-13 13:04:25 +02:00
if (!m_bench_file.is_open())
{
File::OpenFStream(m_bench_file, File::GetUserPath(D_LOGS_IDX) + "render_time.txt",
std::ios_base::out);
}
m_bench_file << std::fixed << std::setprecision(8) << (val / 1000.0) << std::endl;
}
void FPSCounter::Update()
{
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)
{
m_fps = m_frame_counter / (m_time_since_update / 1000000.0);
m_frame_counter = 0;
m_time_since_update = 0;
}
2014-07-02 20:19:08 -04:00
}