2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2012-10-03 21:41:02 -06:00
|
|
|
|
2014-02-10 11:54:46 -07:00
|
|
|
#pragma once
|
2012-10-03 21:41:02 -06:00
|
|
|
|
2014-07-13 05:04:25 -06:00
|
|
|
#include <fstream>
|
|
|
|
|
2017-06-30 01:25:32 -06:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-07-13 05:04:25 -06:00
|
|
|
|
|
|
|
class FPSCounter
|
2014-07-02 18:19:08 -06:00
|
|
|
{
|
2014-07-13 05:04:25 -06:00
|
|
|
public:
|
|
|
|
FPSCounter();
|
2020-12-31 05:03:20 -07:00
|
|
|
~FPSCounter();
|
|
|
|
FPSCounter(const FPSCounter&) = delete;
|
|
|
|
FPSCounter& operator=(const FPSCounter&) = delete;
|
|
|
|
FPSCounter(FPSCounter&&) = delete;
|
|
|
|
FPSCounter& operator=(FPSCounter&&) = delete;
|
2014-07-13 05:04:25 -06:00
|
|
|
|
2015-09-29 07:57:54 -06:00
|
|
|
// Called when a frame is rendered (updated every second).
|
|
|
|
void Update();
|
2014-07-13 05:04:25 -06:00
|
|
|
|
2017-06-30 01:25:32 -06:00
|
|
|
float GetFPS() const { return m_fps; }
|
2020-12-31 05:03:20 -07:00
|
|
|
double GetDeltaTime() const { return m_time_diff_secs; }
|
2018-04-12 06:18:04 -06:00
|
|
|
|
2014-07-13 05:04:25 -06:00
|
|
|
private:
|
2020-12-31 05:03:20 -07:00
|
|
|
void SetPaused(bool paused);
|
|
|
|
|
2017-06-30 01:25:32 -06:00
|
|
|
u64 m_last_time = 0;
|
|
|
|
u64 m_time_since_update = 0;
|
2020-12-31 05:03:20 -07:00
|
|
|
u64 m_last_time_pause = 0;
|
2017-06-30 01:25:32 -06:00
|
|
|
u32 m_frame_counter = 0;
|
2020-12-31 05:03:20 -07:00
|
|
|
int m_on_state_changed_handle = -1;
|
|
|
|
float m_fps = 0.f;
|
2014-07-13 05:04:25 -06:00
|
|
|
std::ofstream m_bench_file;
|
2020-12-31 05:03:20 -07:00
|
|
|
double m_time_diff_secs = 0.0;
|
2014-07-09 14:30:34 -06:00
|
|
|
|
2014-07-13 05:04:25 -06:00
|
|
|
void LogRenderTimeToFile(u64 val);
|
|
|
|
};
|