mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
FPSCounter: Add "Log render time to file" feature.
Allows for a more accurate performance measurement.
This commit is contained in:
@ -20,17 +20,24 @@ static unsigned int s_fps_last_counter = 0;
|
||||
static unsigned long s_last_update_time = 0;
|
||||
static std::ofstream s_bench_file;
|
||||
|
||||
static Common::Timer s_render_time;
|
||||
static std::ofstream s_time_file;
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
s_counter = s_fps_last_counter = 0;
|
||||
s_fps = 0;
|
||||
s_last_update_time = Common::Timer::GetTimeMs();
|
||||
|
||||
s_render_time.Update();
|
||||
|
||||
if (s_bench_file.is_open())
|
||||
s_bench_file.close();
|
||||
if (s_time_file.is_open())
|
||||
s_time_file.close();
|
||||
}
|
||||
|
||||
static void LogFPSToFile(unsigned long val)
|
||||
static void LogFPSToFile(u64 val)
|
||||
{
|
||||
if (!s_bench_file.is_open())
|
||||
s_bench_file.open(File::GetUserPath(D_LOGS_IDX) + "fps.txt");
|
||||
@ -38,6 +45,14 @@ static void LogFPSToFile(unsigned long val)
|
||||
s_bench_file << StringFromFormat("%lu\n", val);
|
||||
}
|
||||
|
||||
static void LogRenderTimeToFile(u64 val)
|
||||
{
|
||||
if (!s_time_file.is_open())
|
||||
s_time_file.open(File::GetUserPath(D_LOGS_IDX) + "render_time.txt");
|
||||
|
||||
s_time_file << StringFromFormat("%lu\n", val);
|
||||
}
|
||||
|
||||
int Update()
|
||||
{
|
||||
if (Common::Timer::GetTimeMs() - s_last_update_time >= FPS_REFRESH_INTERVAL)
|
||||
@ -49,6 +64,12 @@ int Update()
|
||||
LogFPSToFile(s_fps);
|
||||
}
|
||||
|
||||
if (g_ActiveConfig.bLogRenderTimeToFile)
|
||||
{
|
||||
LogRenderTimeToFile(s_render_time.GetTimeDifference());
|
||||
s_render_time.Update();
|
||||
}
|
||||
|
||||
s_counter++;
|
||||
return s_fps;
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ void VideoConfig::Load(const std::string& ini_file)
|
||||
settings->Get("SafeTextureCacheColorSamples", &iSafeTextureCache_ColorSamples,128);
|
||||
settings->Get("ShowFPS", &bShowFPS, false);
|
||||
settings->Get("LogFPSToFile", &bLogFPSToFile, false);
|
||||
settings->Get("LogRenderTimeToFile", &bLogRenderTimeToFile, false);
|
||||
settings->Get("ShowInputDisplay", &bShowInputDisplay, false);
|
||||
settings->Get("OverlayStats", &bOverlayStats, false);
|
||||
settings->Get("OverlayProjStats", &bOverlayProjStats, false);
|
||||
@ -230,6 +231,7 @@ void VideoConfig::Save(const std::string& ini_file)
|
||||
settings->Set("SafeTextureCacheColorSamples", iSafeTextureCache_ColorSamples);
|
||||
settings->Set("ShowFPS", bShowFPS);
|
||||
settings->Set("LogFPSToFile", bLogFPSToFile);
|
||||
settings->Set("LogRenderTimeToFile", bLogRenderTimeToFile);
|
||||
settings->Set("ShowInputDisplay", bShowInputDisplay);
|
||||
settings->Set("OverlayStats", bOverlayStats);
|
||||
settings->Set("OverlayProjStats", bOverlayProjStats);
|
||||
|
@ -84,6 +84,7 @@ struct VideoConfig final
|
||||
bool bTexFmtOverlayCenter;
|
||||
bool bShowEFBCopyRegions;
|
||||
bool bLogFPSToFile;
|
||||
bool bLogRenderTimeToFile;
|
||||
|
||||
// Render
|
||||
bool bWireFrame;
|
||||
|
Reference in New Issue
Block a user