Add the option of starting demo profiling from the command line.

EDuke32 will exit afterwards.

git-svn-id: https://svn.eduke32.com/eduke32@3024 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-09-24 21:09:27 +00:00
parent c04f7cbb4c
commit 2e36784575
4 changed files with 42 additions and 7 deletions

View file

@ -229,9 +229,11 @@ error_wopen_demo:
// demo_profile: < 0: prepare // demo_profile: < 0: prepare
static int32_t g_demo_playFirstFlag, g_demo_profile, g_demo_stopProfile; static int32_t g_demo_playFirstFlag, g_demo_profile, g_demo_stopProfile;
void Demo_PlayFirst(int32_t prof) static int32_t g_demo_exitAfter;
void Demo_PlayFirst(int32_t prof, int32_t exitafter)
{ {
g_demo_playFirstFlag = 1; g_demo_playFirstFlag = 1;
g_demo_exitAfter = exitafter;
Bassert(prof >= 0); Bassert(prof >= 0);
g_demo_profile = -prof; // prepare g_demo_profile = -prof; // prepare
} }
@ -449,6 +451,7 @@ static void Demo_FinishProfile(void)
{ {
double totalprofms = gms+dms1+dms2; double totalprofms = gms+dms1+dms2;
double totalms = gethitickms()-g_prof.starthitickms; double totalms = gethitickms()-g_prof.starthitickms;
if (totalprofms != 0)
OSD_Printf("== demo %d: non-profiled time overhead: %.02f %%\n", OSD_Printf("== demo %d: non-profiled time overhead: %.02f %%\n",
dn, 100.0*totalms/totalprofms - 100.0); dn, 100.0*totalms/totalprofms - 100.0);
} }
@ -469,9 +472,14 @@ int32_t G_PlaybackDemo(void)
if (ready2send) if (ready2send)
return 0; return 0;
if (!g_demo_playFirstFlag)
g_demo_profile = 0; g_demo_profile = 0;
RECHECK: RECHECK:
if (g_demo_playFirstFlag)
g_demo_playFirstFlag = 0;
else if (g_demo_exitAfter)
G_GameExit(" ");
#if KRANDDEBUG #if KRANDDEBUG
if (foundemo) if (foundemo)

View file

@ -48,7 +48,7 @@ void G_CloseDemoWrite(void);
void G_DemoRecord(void); void G_DemoRecord(void);
void G_OpenDemoWrite(void); void G_OpenDemoWrite(void);
void Demo_PlayFirst(int32_t prof); void Demo_PlayFirst(int32_t prof, int32_t exitafter);
int32_t Demo_IsProfiling(void); int32_t Demo_IsProfiling(void);

View file

@ -8943,10 +8943,37 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
ud.m_coop--; ud.m_coop--;
break; break;
case 'd': case 'd':
{
char *colon = Bstrchr(c, ':');
int32_t framespertic=-1, numrepeats=1;
c++; c++;
if (colon && colon != c)
{
// -d<filename>:<num>[,<num>]
// profiling options
*(colon++) = 0;
Bsscanf(colon, "%u,%u", &framespertic, &numrepeats);
}
maybe_append_ext(g_firstDemoFile, sizeof(g_firstDemoFile), c, ".edm"); maybe_append_ext(g_firstDemoFile, sizeof(g_firstDemoFile), c, ".edm");
initprintf("Play demo %s.\n",g_firstDemoFile);
if (framespertic < 0)
{
initprintf("Play demo %s.\n", g_firstDemoFile);
}
else
{
framespertic = clamp(framespertic, 0, 8)+1;
// TODO: repeat count and gathering statistics.
initprintf("Profile demo %s, %d frames/gametic, repeated 1x.\n", g_firstDemoFile,
framespertic-1);
Demo_PlayFirst(framespertic, 1);
g_noLogo = 1;
}
break; break;
}
case 'g': case 'g':
c++; c++;
if (*c) if (*c)

View file

@ -332,7 +332,7 @@ static int32_t osdcmd_demo(const osdfuncparm_t *parm)
else // demo file name passed else // demo file name passed
maybe_append_ext(g_firstDemoFile, sizeof(g_firstDemoFile), parm->parms[0], ".edm"); maybe_append_ext(g_firstDemoFile, sizeof(g_firstDemoFile), parm->parms[0], ".edm");
Demo_PlayFirst(clamp(prof, -1, 8)+1); Demo_PlayFirst(clamp(prof, -1, 8)+1, 0);
} }
return OSDCMD_OK; return OSDCMD_OK;