From 7f043025258a677f89d5d54130a42bfad0552abd Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 12 Nov 2007 10:47:01 +0000 Subject: [PATCH] implemented a -profilegameonly commandline option for profile builds on Linux/FreeBSD (others can be added if they have the moncontrol function) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7687 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_parse.c | 2 ++ host.c | 3 +++ sys.h | 6 ++++++ sys_shared.c | 11 +++++++++++ 4 files changed, 22 insertions(+) diff --git a/cl_parse.c b/cl_parse.c index 4061b81f..2a906d35 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -1380,6 +1380,8 @@ static void CL_SignonReply (void) case 4: Con_ClearNotify(); + if (COM_CheckParm("-profilegameonly")) + Sys_AllowProfiling(true); break; } } diff --git a/host.c b/host.c index db4c9899..36fa7ac5 100644 --- a/host.c +++ b/host.c @@ -918,6 +918,9 @@ static void Host_Init (void) int i; const char* os; + if (COM_CheckParm("-profilegameonly")) + Sys_AllowProfiling(false); + // LordHavoc: quake never seeded the random number generator before... heh if (COM_CheckParm("-benchmark")) srand(0); // predictable random sequence for -benchmark diff --git a/sys.h b/sys.h index 42838e31..23f16b27 100644 --- a/sys.h +++ b/sys.h @@ -70,6 +70,12 @@ void Sys_PrintToTerminal(const char *text); void Sys_Shutdown (void); //INFO: This is only called by Host_Shutdown so we dont need testing for recursion void Sys_Quit (int returnvalue); +// on some build/platform combinations (such as Linux gcc with the -pg +// profiling option) this can turn on/off profiling, used primarily to limit +// profiling to certain areas of the code, such as ingame performance without +// regard for loading/shutdown performance (-profilegameonly on commandline) +void Sys_AllowProfiling (qboolean enable); + double Sys_DoubleTime (void); char *Sys_ConsoleInput (void); diff --git a/sys_shared.c b/sys_shared.c index 64ca6abf..e332f23b 100644 --- a/sys_shared.c +++ b/sys_shared.c @@ -18,11 +18,22 @@ char *Sys_TimeString(const char *timeformat) extern qboolean host_shuttingdown; void Sys_Quit (int returnvalue) { + if (COM_CheckParm("-profilegameonly")) + Sys_AllowProfiling(false); host_shuttingdown = true; Host_Shutdown(); exit(returnvalue); } +void Sys_AllowProfiling(qboolean enable) +{ +#if defined(__linux__) || defined(__FreeBSD__) +int moncontrol(int); + moncontrol(enable); +#endif +} + + /* =============================================================================== -- 2.39.2