mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 12:52:46 +00:00
timeframes patch I made so long ago. use cl_timeframes 1 before
running a demo, and when it stops it'll print out the time spent on each frame (in microseconds) to timeframes.txt.
This commit is contained in:
parent
0d82df96b0
commit
cd99a6a4b6
3 changed files with 96 additions and 0 deletions
|
@ -42,4 +42,8 @@ void CL_ReRecord_f (void);
|
|||
void CL_PlayDemo_f (void);
|
||||
void CL_TimeDemo_f (void);
|
||||
|
||||
void CL_TimeFrames_Init (void);
|
||||
void CL_TimeFrames_Reset (void);
|
||||
void CL_TimeFrames_AddTimestamp (void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -36,12 +36,16 @@
|
|||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "QF/console.h"
|
||||
#include "QF/cmd.h"
|
||||
#include "QF/msg.h"
|
||||
#include "QF/qendian.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/va.h"
|
||||
#include "QF/cvar.h"
|
||||
|
||||
#include "compat.h"
|
||||
#include "cl_main.h"
|
||||
|
@ -49,6 +53,15 @@
|
|||
#include "host.h"
|
||||
#include "pmove.h"
|
||||
|
||||
int cl_timeframes_isactive;
|
||||
int cl_timeframes_index;
|
||||
struct timeval *cl_timeframes_array;
|
||||
#define CL_TIMEFRAMES_ARRAYBLOCK 4096
|
||||
extern cvar_t *cl_timeframes;
|
||||
|
||||
void CL_TimeFrames_Reset (void);
|
||||
void CL_TimeFrames_DumpLog (void);
|
||||
|
||||
void CL_FinishTimeDemo (void);
|
||||
int demotime_cached;
|
||||
|
||||
|
@ -773,6 +786,9 @@ CL_FinishTimeDemo (void)
|
|||
time = 1;
|
||||
Con_Printf ("%i frames %5.1f seconds %5.2f fps\n", frames, time,
|
||||
frames / time);
|
||||
|
||||
CL_TimeFrames_DumpLog();
|
||||
cl_timeframes_isactive = 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -801,4 +817,72 @@ CL_TimeDemo_f (void)
|
|||
cls.td_starttime = 0;
|
||||
cls.td_startframe = host_framecount;
|
||||
cls.td_lastframe = -1; // get a new message this frame
|
||||
|
||||
CL_TimeFrames_Reset ();
|
||||
if (cl_timeframes->int_val)
|
||||
cl_timeframes_isactive = 1;
|
||||
}
|
||||
|
||||
void
|
||||
CL_TimeFrames_Init (void)
|
||||
{
|
||||
cl_timeframes_isactive = 0;
|
||||
cl_timeframes_index = 0;
|
||||
cl_timeframes_array = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
CL_TimeFrames_Reset (void)
|
||||
{
|
||||
cl_timeframes_index = 0;
|
||||
free(cl_timeframes_array);
|
||||
cl_timeframes_array = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
CL_TimeFrames_AddTimestamp (void)
|
||||
{
|
||||
int retval;
|
||||
if (cl_timeframes_isactive) {
|
||||
if (!(cl_timeframes_index % CL_TIMEFRAMES_ARRAYBLOCK))
|
||||
cl_timeframes_array = realloc (cl_timeframes_array, sizeof(struct timeval) * ((cl_timeframes_index / CL_TIMEFRAMES_ARRAYBLOCK) + 1) * CL_TIMEFRAMES_ARRAYBLOCK);
|
||||
if (cl_timeframes_array == NULL)
|
||||
Sys_Error ("Unable to allocate timeframes buffer\n");
|
||||
retval = gettimeofday(cl_timeframes_array + cl_timeframes_index, NULL);
|
||||
if (retval)
|
||||
Sys_Error ("CL_TimeFrames_Addtimestamp: gettimeofday() failed.\n");
|
||||
cl_timeframes_index++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void CL_TimeFrames_DumpLog (void)
|
||||
{
|
||||
VFile *outputfile;
|
||||
char e_path[MAX_OSPATH];
|
||||
char *filename = "timeframes.txt";
|
||||
int i;
|
||||
long frame;
|
||||
|
||||
if (cl_timeframes_isactive == 0)
|
||||
return;
|
||||
|
||||
Qexpand_squiggle (fs_userpath->string, e_path);
|
||||
Con_Printf ("Dumping Timed Frames log: %s\n", filename);
|
||||
outputfile = Qopen (va ("%s/%s", e_path, filename), "w");
|
||||
if (!outputfile) {
|
||||
Con_Printf ("Could not open: %s\n", filename);
|
||||
return;
|
||||
}
|
||||
for (i = 1; i < cl_timeframes_index; i++) {
|
||||
frame = (cl_timeframes_array[i].tv_sec - cl_timeframes_array[i - 1].tv_sec);
|
||||
if (frame < 999) {
|
||||
frame *= 1000000;
|
||||
frame += cl_timeframes_array[i].tv_usec - cl_timeframes_array[i - 1].tv_usec;
|
||||
} else
|
||||
frame = 999999999;
|
||||
|
||||
Qprintf (outputfile, "%09ld\n", frame);
|
||||
}
|
||||
Qclose (outputfile);
|
||||
}
|
||||
|
|
|
@ -124,6 +124,8 @@ cvar_t *rcon_address;
|
|||
cvar_t *cl_writecfg;
|
||||
cvar_t *cl_allow_cmd_pkt;
|
||||
|
||||
cvar_t *cl_timeframes;
|
||||
|
||||
cvar_t *cl_timeout;
|
||||
|
||||
cvar_t *cl_shownet;
|
||||
|
@ -1291,6 +1293,8 @@ CL_Init_Cvars (void)
|
|||
localid = Cvar_Get ("localid", "", CVAR_NONE, NULL, "FIXME: This has "
|
||||
"something to do with client authentication."
|
||||
"No description");
|
||||
cl_timeframes = Cvar_Get ("cl_timeframes", "0", CVAR_ARCHIVE, NULL,
|
||||
"write timestamps for every frame");
|
||||
|
||||
// info mirrors
|
||||
//
|
||||
|
@ -1540,6 +1544,8 @@ Host_Frame (float time)
|
|||
pass1 + pass2 + pass3, pass1, pass2, pass3);
|
||||
}
|
||||
|
||||
CL_TimeFrames_AddTimestamp ();
|
||||
|
||||
host_framecount++;
|
||||
fps_count++;
|
||||
}
|
||||
|
@ -1659,6 +1665,8 @@ Host_Init (void)
|
|||
Con_Init ("client");
|
||||
Mod_Init ();
|
||||
|
||||
CL_TimeFrames_Init();
|
||||
|
||||
// Con_Printf ("Exe: "__TIME__" "__DATE__"\n");
|
||||
Con_Printf ("%4.1f megs RAM used.\n", host_parms.memsize / (1024 * 1024.0));
|
||||
|
||||
|
|
Loading…
Reference in a new issue