blob: 10bfebb26f72434676fc41fef37b0c8604059793 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <fstream>
#include "Common/FileUtil.h"
#include "Common/StringUtil.h"
#include "Common/Timer.h"
#include "VideoCommon/FPSCounter.h"
#include "VideoCommon/VideoConfig.h"
namespace FPSCounter
{
#define FPS_REFRESH_INTERVAL 1000
static unsigned int s_counter = 0;
static unsigned int s_fps = 0;
static unsigned int s_fps_last_counter = 0;
static Common::Timer s_update_time;
static Common::Timer s_render_time;
static std::ofstream s_bench_file;
void Initialize()
{
s_counter = s_fps_last_counter = 0;
s_fps = 0;
s_update_time.Update();
s_render_time.Update();
if (s_bench_file.is_open())
s_bench_file.close();
}
static void LogRenderTimeToFile(u64 val)
{
if (!s_bench_file.is_open())
s_bench_file.open(File::GetUserPath(D_LOGS_IDX) + "render_time.txt");
s_bench_file << val << std::endl;
}
int Update()
{
if (s_update_time.GetTimeDifference() >= FPS_REFRESH_INTERVAL)
{
s_update_time.Update();
s_fps = s_counter - s_fps_last_counter;
s_fps_last_counter = s_counter;
}
if (g_ActiveConfig.bLogRenderTimeToFile)
{
LogRenderTimeToFile(s_render_time.GetTimeDifference());
s_render_time.Update();
}
s_counter++;
return s_fps;
}
}
|