set currtime before Qcommon_Frame once

Make Qcommon_Frame and Qcommon_Mainloop static and minimize calls
for get current time, it takes 7% in some profiling cases.

We get current time twice before Qcommon_Frame(as Sys_Microseconds)
and inside it(as Sys_Milliseconds), and we can do it once.
This commit is contained in:
Denis Pauk 2021-10-16 14:09:22 +03:00
parent 11bb96401f
commit 012862b58d
2 changed files with 9 additions and 13 deletions

View file

@ -81,6 +81,8 @@ char userGivenGame[MAX_QPATH];
// Hack for the signal handlers.
qboolean quitnextframe;
static void Qcommon_Frame(int usec);
// ----
static void
@ -130,7 +132,7 @@ Qcommon_Buildstring(void)
printf("Architecture: %s\n", YQ2ARCH);
}
void
static void
Qcommon_Mainloop(void)
{
long long newtime;
@ -173,6 +175,10 @@ Qcommon_Mainloop(void)
#endif
newtime = Sys_Microseconds();
// Save global time for network- und input code.
curtime = (int)(newtime / 1000ll);
Qcommon_Frame(newtime - oldtime);
oldtime = newtime;
}
@ -392,7 +398,7 @@ Qcommon_Init(int argc, char **argv)
}
#ifndef DEDICATED_ONLY
void
static void
Qcommon_Frame(int usec)
{
// Used for the dedicated server console.
@ -523,11 +529,6 @@ Qcommon_Frame(int usec)
Cvar_SetValue("cl_maxfps", 60);
}
// Save global time for network- und input code.
curtime = Sys_Milliseconds();
// Calculate target and renderframerate.
if (R_IsVSyncActive())
{
@ -668,7 +669,7 @@ Qcommon_Frame(int usec)
}
}
#else
void
static void
Qcommon_Frame(int usec)
{
// For the dedicated server terminal console.
@ -720,10 +721,6 @@ Qcommon_Frame(int usec)
}
// Save global time for network- und input code.
curtime = Sys_Milliseconds();
// Target framerate.
pfps = (int)cl_maxfps->value;

View file

@ -780,7 +780,6 @@ void Z_FreeTags(int tag);
void Qcommon_Init(int argc, char **argv);
void Qcommon_ExecConfigs(qboolean addEarlyCmds);
const char* Qcommon_GetInitialGame(void);
void Qcommon_Frame(int msec);
void Qcommon_Shutdown(void);
#define NUMVERTEXNORMALS 162