diff options
| author | Jasper St. Pierre <jstpierre@mecheye.net> | 2013-12-07 15:14:29 -0500 |
|---|---|---|
| committer | Jasper St. Pierre <jstpierre@mecheye.net> | 2013-12-31 14:03:19 -0500 |
| commit | 34692ab826abc8f8faa61bdb2280b742424528f1 (patch) | |
| tree | b0eedc645badbea316ff59c125eaf808b28777ec /Source/Core/VideoCommon/FPSCounter.cpp | |
| parent | 43e618682e8093602fc83dfa902ee7ae3fd3a4f6 (diff) | |
Remove unnecessary Src/ folders
Diffstat (limited to 'Source/Core/VideoCommon/FPSCounter.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/FPSCounter.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/FPSCounter.cpp b/Source/Core/VideoCommon/FPSCounter.cpp new file mode 100644 index 0000000000..d9464afedc --- /dev/null +++ b/Source/Core/VideoCommon/FPSCounter.cpp @@ -0,0 +1,51 @@ +// Copyright 2013 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#include "FPSCounter.h" +#include "FileUtil.h" +#include "Timer.h" +#include "VideoConfig.h" + +#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 unsigned long s_last_update_time = 0; +static File::IOFile s_bench_file; + +void InitFPSCounter() +{ + s_counter = s_fps_last_counter = 0; + s_fps = 0; + s_last_update_time = Common::Timer::GetTimeMs(); + + if (s_bench_file.IsOpen()) + s_bench_file.Close(); +} + +static void LogFPSToFile(unsigned long val) +{ + if (!s_bench_file.IsOpen()) + s_bench_file.Open(File::GetUserPath(D_LOGS_IDX) + "fps.txt", "w"); + + char buffer[256]; + snprintf(buffer, 256, "%ld\n", val); + s_bench_file.WriteArray(buffer, strlen(buffer)); +} + +int UpdateFPSCounter() +{ + if (Common::Timer::GetTimeMs() - s_last_update_time >= FPS_REFRESH_INTERVAL) + { + s_last_update_time = Common::Timer::GetTimeMs(); + s_fps = s_counter - s_fps_last_counter; + s_fps_last_counter = s_counter; + if (g_ActiveConfig.bLogFPSToFile) + LogFPSToFile(s_fps); + } + + s_counter++; + return s_fps; +}
\ No newline at end of file |
