]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
implemented a -profilegameonly commandline option for profile builds on
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 12 Nov 2007 10:47:01 +0000 (10:47 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 12 Nov 2007 10:47:01 +0000 (10:47 +0000)
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
host.c
sys.h
sys_shared.c

index 4061b81f15dacd593ffc5886a63fd4c6311bdf47..2a906d35d7cf1bd7a002625221700197754d148b 100644 (file)
@@ -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 db4c9899c68b3a75f4c8bc2d6c255b93b84e4d97..36fa7ac59e621588c30878e616c7afa415107c3e 100644 (file)
--- 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 42838e319f9b658e4bba3ae6840303e799e34031..23f16b2781ae1440652216855e962a92a597e7cc 100644 (file)
--- 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);
index 64ca6abfb29961211dbfb9854c03b3aa03e412f5..e332f23b110246310393d4dd5d5fbc8cd2bb7d93 100644 (file)
@@ -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
+}
+
+
 /*
 ===============================================================================