mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-18 01:51:39 +00:00
Add CSV functionality to timedemo
* Append timedemo trials to timedemo.csv * Specify -csv <trialid> to toggle CSV behavior * Specify -quit to immediately quit after timedemo * Add ticrate, rendermode, video mode, demo name, bits to CSV timedemo row
This commit is contained in:
parent
56892c13ab
commit
b3908755af
4 changed files with 73 additions and 8 deletions
|
@ -4596,7 +4596,12 @@ void TryRunTics(tic_t realtics)
|
|||
if (neededtic > gametic)
|
||||
{
|
||||
if (advancedemo)
|
||||
D_StartTitle();
|
||||
{
|
||||
if (timedemo_quit)
|
||||
COM_ImmedExecute("quit");
|
||||
else
|
||||
D_StartTitle();
|
||||
}
|
||||
else
|
||||
// run the count * tics
|
||||
while (neededtic > gametic)
|
||||
|
|
|
@ -364,6 +364,11 @@ consvar_t cv_mute = {"mute", "Off", CV_NETVAR|CV_CALL, CV_OnOff, Mute_OnChange,
|
|||
|
||||
consvar_t cv_sleep = {"cpusleep", "-1", CV_SAVE, sleeping_cons_t, NULL, -1, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
char timedemo_name[256];
|
||||
boolean timedemo_csv;
|
||||
char timedemo_csv_id[256];
|
||||
boolean timedemo_quit;
|
||||
|
||||
INT16 gametype = GT_COOP;
|
||||
boolean splitscreen = false;
|
||||
boolean circuitmap = false;
|
||||
|
@ -1479,11 +1484,11 @@ static void Command_Playdemo_f(void)
|
|||
|
||||
static void Command_Timedemo_f(void)
|
||||
{
|
||||
char name[256];
|
||||
size_t i = 0;
|
||||
|
||||
if (COM_Argc() != 2)
|
||||
if (COM_Argc() < 2)
|
||||
{
|
||||
CONS_Printf(M_GetText("timedemo <demoname>: time a demo\n"));
|
||||
CONS_Printf(M_GetText("timedemo <demoname> [-csv [<trialid>]] [-quit]: time a demo\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1500,12 +1505,23 @@ static void Command_Timedemo_f(void)
|
|||
G_StopMetalDemo();
|
||||
|
||||
// open the demo file
|
||||
strcpy (name, COM_Argv(1));
|
||||
strcpy (timedemo_name, COM_Argv(1));
|
||||
// dont add .lmp so internal game demos can be played
|
||||
|
||||
CONS_Printf(M_GetText("Timing demo '%s'.\n"), name);
|
||||
// print timedemo results as CSV?
|
||||
i = COM_CheckParm("-csv");
|
||||
timedemo_csv = (i > 0);
|
||||
if (COM_CheckParm("-quit") != i + 1)
|
||||
strcpy(timedemo_csv_id, COM_Argv(i + 1)); // user-defined string to identify row
|
||||
else
|
||||
timedemo_csv_id[0] = 0;
|
||||
|
||||
G_TimeDemo(name);
|
||||
// exit after the timedemo?
|
||||
timedemo_quit = (COM_CheckParm("-quit") > 0);
|
||||
|
||||
CONS_Printf(M_GetText("Timing demo '%s'.\n"), timedemo_name);
|
||||
|
||||
G_TimeDemo(timedemo_name);
|
||||
}
|
||||
|
||||
// stop current demo
|
||||
|
|
|
@ -111,6 +111,11 @@ extern consvar_t cv_skipmapcheck;
|
|||
|
||||
extern consvar_t cv_sleep;
|
||||
|
||||
extern char timedemo_name[256];
|
||||
extern boolean timedemo_csv;
|
||||
extern char timedemo_csv_id[256];
|
||||
extern boolean timedemo_quit;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
XD_NAMEANDCOLOR = 1,
|
||||
|
|
41
src/g_game.c
41
src/g_game.c
|
@ -5660,7 +5660,46 @@ boolean G_CheckDemoStatus(void)
|
|||
timingdemo = false;
|
||||
f1 = (double)demotime;
|
||||
f2 = (double)framecount*TICRATE;
|
||||
CONS_Printf(M_GetText("timed %u gametics in %d realtics - %u frames\n%f seconds, %f avg fps\n"), leveltime,demotime,(UINT32)framecount,f1/TICRATE,f2/f1);
|
||||
|
||||
CONS_Printf(M_GetText("timed %u gametics in %d realtics - %u frames\n%f seconds, %f avg fps\n"),
|
||||
leveltime,demotime,(UINT32)framecount,f1/TICRATE,f2/f1);
|
||||
|
||||
// CSV-readable timedemo results, for external parsing
|
||||
if (timedemo_csv)
|
||||
{
|
||||
FILE *f;
|
||||
const char *csvpath = va("%s"PATHSEP"%s", srb2home, "timedemo.csv");
|
||||
const char *header = "id,demoname,seconds,avgfps,leveltime,demotime,framecount,ticrate,rendermode,vidmode,vidwidth,vidheight,procbits\n";
|
||||
const char *rowformat = "\"%s\",\"%s\",%f,%f,%u,%d,%u,%u,%u,%u,%u,%u,%u\n";
|
||||
boolean headerrow = !FIL_FileExists(csvpath);
|
||||
UINT8 procbits = 0;
|
||||
|
||||
// Bitness
|
||||
if (sizeof(void*) == 4)
|
||||
procbits = 32;
|
||||
else if (sizeof(void*) == 8)
|
||||
procbits = 64;
|
||||
|
||||
f = fopen(csvpath, "a+");
|
||||
|
||||
if (f)
|
||||
{
|
||||
if (headerrow)
|
||||
fputs(header, f);
|
||||
fprintf(f, rowformat,
|
||||
timedemo_csv_id,timedemo_name,f1/TICRATE,f2/f1,leveltime,demotime,(UINT32)framecount,TICRATE,rendermode,vid.modenum,vid.width,vid.height,procbits);
|
||||
fclose(f);
|
||||
CONS_Printf("Timedemo results saved to '%s'\n", csvpath);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Just print the CSV output to console
|
||||
CON_LogMessage(header);
|
||||
CONS_Printf(rowformat,
|
||||
timedemo_csv_id,timedemo_name,f1/TICRATE,f2/f1,leveltime,demotime,(UINT32)framecount,TICRATE,rendermode,vid.modenum,vid.width,vid.height,procbits);
|
||||
}
|
||||
}
|
||||
|
||||
if (restorecv_vidwait != cv_vidwait.value)
|
||||
CV_SetValue(&cv_vidwait, restorecv_vidwait);
|
||||
D_AdvanceDemo();
|
||||
|
|
Loading…
Reference in a new issue