]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
changed qc profiling to use doubles instead of ints for profile counters, so it can...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 25 May 2006 03:57:50 +0000 (03:57 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 25 May 2006 03:57:50 +0000 (03:57 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6379 d7cf8633-e32d-0410-b094-e92efae38249

pr_comp.h
progsvm.h
prvm_edict.c
prvm_exec.c

index 912491e6ffd9334ed9a3663e9708a8e40d9bf467..8ccdaf6d74ace96f3ca9a6909ebbb1a6692942c1 100644 (file)
--- a/pr_comp.h
+++ b/pr_comp.h
@@ -163,9 +163,10 @@ typedef struct mfunction_s
        int             parm_start;
        int             locals;                         // total ints of parms + locals
 
-       int             profile;                // runtime
-       int             builtinsprofile; // cost of builtin functions called by this function
-       int             callcount; // times the functions has been called since the last profile call
+       // these are doubles so that they can count up to 54bits or so rather than 32bit
+       double  profile;                // runtime
+       double  builtinsprofile; // cost of builtin functions called by this function
+       double  callcount; // times the functions has been called since the last profile call
 
        int             s_name;
        int             s_file;                 // source file defined in
index 8f77619da01977c686f19fa9a83710423bb0807a..8270615d4fd830aa5256302a42364b9a99e63997 100644 (file)
--- a/progsvm.h
+++ b/progsvm.h
@@ -266,7 +266,7 @@ typedef struct prvm_prog_s
 
        int                                     *statement_linenums; // NULL if not available
 
-       int                                     *statement_profile; // only incremented if prvm_statementprofiling is on
+       double                          *statement_profile; // only incremented if prvm_statementprofiling is on
 
        union {
                float *generic;
index 29e5998a775d3e31780894c6d095b80251051a14..68f5197aed5ad57c79c72ec0fa87f84acb6d6030 100644 (file)
@@ -1349,7 +1349,7 @@ void PRVM_LoadProgs (const char * filename, int numrequiredfunc, char **required
 
        prog->statements = (dstatement_t *)((unsigned char *)prog->progs + prog->progs->ofs_statements);
 
-       prog->statement_profile = (int *)Mem_Alloc(prog->progs_mempool, prog->progs->numstatements * sizeof(*prog->statement_profile));
+       prog->statement_profile = (double *)Mem_Alloc(prog->progs_mempool, prog->progs->numstatements * sizeof(*prog->statement_profile));
 
        // moved edict_size calculation down below field adding code
 
index eb8aa349718b224f67b5690f864706c2df9b0a9a..e7fb591a04550789d74c5e709c6d699aa842d70b 100644 (file)
@@ -132,7 +132,7 @@ void PRVM_PrintStatement (dstatement_t *s)
                Con_Printf( "%s:%i: ", PRVM_GetString( prog->xfunction->s_file ), prog->statement_linenums[ opnum ] );
 
        if (prvm_statementprofiling.integer)
-               Con_Printf("%7i ", prog->statement_profile[s - prog->statements]);
+               Con_Printf("%7.0f ", prog->statement_profile[s - prog->statements]);
 
        if ( (unsigned)s->op < sizeof(prvm_opnames)/sizeof(prvm_opnames[0]))
        {
@@ -275,12 +275,13 @@ PRVM_Profile_f
 void PRVM_Profile_f (void)
 {
        mfunction_t *f, *best;
-       int i, num, max/*, howmany*/;
+       int i, num, howmany;
+       double max;
 
-       //howmany = 10;
-       //if (Cmd_Argc() == 2)
-       //      howmany = atoi(Cmd_Argv(1));
-       if(Cmd_Argc() != 2)
+       howmany = 1<<30;
+       if (Cmd_Argc() == 3)
+               howmany = atoi(Cmd_Argv(2));
+       else if (Cmd_Argc() != 2)
        {
                Con_Print("prvm_profile <program name>\n");
                return;
@@ -308,11 +309,13 @@ void PRVM_Profile_f (void)
                }
                if (best)
                {
-                       //if (num < howmany)
-                       if (best->first_statement < 0)
-                               Con_Printf("%10i ----- builtin ----- %s\n", best->callcount, PRVM_GetString(best->s_name));
-                       else
-                               Con_Printf("%10i%10i%10i %s\n", best->callcount, best->profile, best->builtinsprofile, PRVM_GetString(best->s_name));
+                       if (num < howmany)
+                       {
+                               if (best->first_statement < 0)
+                                       Con_Printf("%9.0f ----- builtin ----- %s\n", best->callcount, PRVM_GetString(best->s_name));
+                               else
+                                       Con_Printf("%9.0f %9.0f %9.0f %s\n", best->callcount, best->profile, best->builtinsprofile, PRVM_GetString(best->s_name));
+                       }
                        num++;
                        best->profile = 0;
                        best->builtinsprofile = 0;