2015-05-24 06:55:12 +02:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2021-07-05 03:22:19 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2012-10-04 05:41:02 +02:00
|
|
|
|
2014-02-10 13:54:46 -05:00
|
|
|
#pragma once
|
2012-10-04 05:41:02 +02:00
|
|
|
|
2022-10-26 15:17:15 -04:00
|
|
|
#include <deque>
|
2014-07-13 13:04:25 +02:00
|
|
|
#include <fstream>
|
|
|
|
|
2017-06-30 17:25:32 +10:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-07-13 13:04:25 +02:00
|
|
|
|
|
|
|
class FPSCounter
|
2014-07-02 20:19:08 -04:00
|
|
|
{
|
2014-07-13 13:04:25 +02:00
|
|
|
public:
|
2022-10-26 15:17:15 -04:00
|
|
|
explicit FPSCounter(const char* log_name = "log.txt");
|
2020-12-31 14:03:20 +02:00
|
|
|
~FPSCounter();
|
|
|
|
FPSCounter(const FPSCounter&) = delete;
|
|
|
|
FPSCounter& operator=(const FPSCounter&) = delete;
|
|
|
|
FPSCounter(FPSCounter&&) = delete;
|
|
|
|
FPSCounter& operator=(FPSCounter&&) = delete;
|
2014-07-13 13:04:25 +02:00
|
|
|
|
2015-09-29 09:57:54 -04:00
|
|
|
// Called when a frame is rendered (updated every second).
|
|
|
|
void Update();
|
2014-07-13 13:04:25 +02:00
|
|
|
|
2022-10-26 15:17:15 -04:00
|
|
|
double GetFPS() const { return m_avg_fps; }
|
|
|
|
|
|
|
|
double GetDeltaTime() const { return m_raw_dt; }
|
2018-04-12 14:18:04 +02:00
|
|
|
|
2014-07-13 13:04:25 +02:00
|
|
|
private:
|
2022-10-26 15:17:15 -04:00
|
|
|
void LogRenderTimeToFile(s64 val);
|
2020-12-31 14:03:20 +02:00
|
|
|
void SetPaused(bool paused);
|
|
|
|
|
2022-10-26 15:17:15 -04:00
|
|
|
const char* m_log_name;
|
2014-07-13 13:04:25 +02:00
|
|
|
std::ofstream m_bench_file;
|
2014-07-09 22:30:34 +02:00
|
|
|
|
2022-10-26 15:17:15 -04:00
|
|
|
bool m_paused = false;
|
|
|
|
s64 m_last_time = 0;
|
|
|
|
|
|
|
|
double m_avg_fps = 0.0;
|
|
|
|
double m_raw_dt = 0.0;
|
|
|
|
|
|
|
|
s64 m_dt_total = 0;
|
|
|
|
std::deque<s64> m_dt_queue;
|
|
|
|
|
|
|
|
int m_on_state_changed_handle = -1;
|
|
|
|
s64 m_last_time_pause = 0;
|
2014-07-13 13:04:25 +02:00
|
|
|
};
|