From 90c7b73cb4726de4318b54a146c54a43ebbe667a Mon Sep 17 00:00:00 2001 From: havoc Date: Thu, 28 Feb 2008 10:01:04 +0000 Subject: [PATCH] reworked min/avg/max fps report in timedemo, now works again git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8156 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_demo.c | 29 ++++++++++++++++------------- client.h | 7 ++++--- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/cl_demo.c b/cl_demo.c index c72b3b8a..8a93daf6 100644 --- a/cl_demo.c +++ b/cl_demo.c @@ -155,22 +155,25 @@ void CL_ReadDemoMessage(void) { cls.td_starttime = realtime; cls.td_onesecondnexttime = cl.time + 1; + cls.td_onesecondrealtime = realtime; cls.td_onesecondframes = 0; - cls.td_onesecondminframes = 0; - cls.td_onesecondmaxframes = 0; - cls.td_onesecondavgframes = 0; + cls.td_onesecondminfps = 0; + cls.td_onesecondmaxfps = 0; + cls.td_onesecondavgfps = 0; cls.td_onesecondavgcount = 0; } if (cl.time >= cls.td_onesecondnexttime) { + double fps = cls.td_onesecondframes / (realtime - cls.td_onesecondrealtime); if (cls.td_onesecondavgcount == 0) { - cls.td_onesecondminframes = cls.td_onesecondframes; - cls.td_onesecondmaxframes = cls.td_onesecondframes; + cls.td_onesecondminfps = fps; + cls.td_onesecondmaxfps = fps; } - cls.td_onesecondminframes = min(cls.td_onesecondminframes, cls.td_onesecondframes); - cls.td_onesecondmaxframes = max(cls.td_onesecondmaxframes, cls.td_onesecondframes); - cls.td_onesecondavgframes += cls.td_onesecondframes; + cls.td_onesecondrealtime = realtime; + cls.td_onesecondminfps = min(cls.td_onesecondminfps, fps); + cls.td_onesecondmaxfps = max(cls.td_onesecondmaxfps, fps); + cls.td_onesecondavgfps += fps; cls.td_onesecondavgcount++; cls.td_onesecondframes = 0; cls.td_onesecondnexttime++; @@ -394,12 +397,12 @@ void CL_FinishTimeDemo (void) frames = cls.td_frames; time = realtime - cls.td_starttime; totalfpsavg = time > 0 ? frames / time : 0; - fpsmin = cls.td_onesecondminframes; - fpsavg = cls.td_onesecondavgcount ? cls.td_onesecondavgframes / cls.td_onesecondavgcount : 0; - fpsmax = cls.td_onesecondmaxframes; + fpsmin = cls.td_onesecondminfps; + fpsavg = cls.td_onesecondavgcount ? cls.td_onesecondavgfps / cls.td_onesecondavgcount : 0; + fpsmax = cls.td_onesecondmaxfps; // LordHavoc: timedemo now prints out 7 digits of fraction, and min/avg/max - Con_Printf("%i frames %5.7f seconds %5.7f fps, one-second min/avg/max: %.0f %.0f %.0f\n", frames, time, totalfpsavg, fpsmin, fpsavg, fpsmax); - Log_Printf("benchmark.log", "date %s | enginedate %s | demo %s | commandline %s | result %i frames %5.7f seconds %5.7f fps, one-second min/avg/max: %.0f %.0f %.0f\n", Sys_TimeString("%Y-%m-%d %H:%M:%S"), buildstring, cls.demoname, cmdline.string, frames, time, totalfpsavg, fpsmin, fpsavg, fpsmax); + Con_Printf("%i frames %5.7f seconds %5.7f fps, one-second fps min/avg/max: %.0f %.0f %.0f (%i seconds)\n", frames, time, totalfpsavg, fpsmin, fpsavg, fpsmax, cls.td_onesecondavgcount); + Log_Printf("benchmark.log", "date %s | enginedate %s | demo %s | commandline %s | result %i frames %5.7f seconds %5.7f fps, one-second fps min/avg/max: %.0f %.0f %.0f (%i seconds)\n", Sys_TimeString("%Y-%m-%d %H:%M:%S"), buildstring, cls.demoname, cmdline.string, frames, time, totalfpsavg, fpsmin, fpsavg, fpsmax, cls.td_onesecondavgcount); if (COM_CheckParm("-benchmark")) Host_Quit_f(); } diff --git a/client.h b/client.h index fe483591..543c9b7b 100644 --- a/client.h +++ b/client.h @@ -518,9 +518,10 @@ typedef struct client_static_s int td_frames; // total frames parsed double td_onesecondnexttime; double td_onesecondframes; - double td_onesecondminframes; - double td_onesecondmaxframes; - double td_onesecondavgframes; + double td_onesecondrealtime; + double td_onesecondminfps; + double td_onesecondmaxfps; + double td_onesecondavgfps; int td_onesecondavgcount; // LordHavoc: pausedemo qboolean demopaused; -- 2.39.2