-Added the callcount field to the mfunction_t structure.
authorblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 20 May 2005 19:20:39 +0000 (19:20 +0000)
committerblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 20 May 2005 19:20:39 +0000 (19:20 +0000)
-Both vms now record how often a function has been called and the profile cmd
 now outputs the callcount with the other information.

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5319 d7cf8633-e32d-0410-b094-e92efae38249

pr_comp.h
pr_exec.c
pr_execprogram.h
prvm_exec.c
prvm_execprogram.h

index 7a74464..46fdc6b 100644 (file)
--- a/pr_comp.h
+++ b/pr_comp.h
@@ -161,6 +161,7 @@ typedef struct
 
        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
 
        int             s_name;
        int             s_file;                 // source file defined in
index c516fec..2393ed1 100644 (file)
--- a/pr_exec.c
+++ b/pr_exec.c
@@ -221,6 +221,8 @@ void PR_Profile_f (void)
                return;
        }
 
+       Con_Print( "Server Profile:\n[Profile] [BuiltinProfile] [CallCount]\n" );
+
        //howmany = 10;
        //if (Cmd_Argc() == 2)
        //      howmany = atoi(Cmd_Argv(1));
@@ -241,7 +243,7 @@ void PR_Profile_f (void)
                if (best)
                {
                        //if (num < howmany)
-                               Con_Printf("%7i %7i %s\n", best->profile, best->builtinsprofile, PR_GetString(best->s_name));
+                               Con_Printf("%7i %7i %7i %s\n", best->profile, best->builtinsprofile, best->callcount, PR_GetString(best->s_name));
                        num++;
                        best->profile = 0;
                        best->builtinsprofile = 0;
index 5089e27..3ea2241 100644 (file)
                                        Host_Error("Bad function number");
 
                                newf = &pr_functions[OPA->function];
+                               newf->callcount++;
 
                                if (newf->first_statement < 0)
                                {
index 47ab908..428a158 100644 (file)
@@ -199,11 +199,13 @@ void PRVM_Profile_f (void)
                Con_Print("prvm_profile <program name>\n");
                return;
        }
-
+       
        PRVM_Begin;
        if(!PRVM_SetProgFromString(Cmd_Argv(1)))
                return;
 
+       Con_Printf( "%s Profile:\n[Profile] [BuiltinProfile] [CallCount]\n", PRVM_NAME );
+
        num = 0;
        do
        {
@@ -221,7 +223,7 @@ void PRVM_Profile_f (void)
                if (best)
                {
                        //if (num < howmany)
-                               Con_Printf("%s: %7i %7i %s\n", PRVM_NAME, best->profile, best->builtinsprofile, PRVM_GetString(best->s_name));
+                               Con_Printf("%7i %7i %7i %s\n", best->profile, best->builtinsprofile, best->callcount, PRVM_GetString(best->s_name));
                        num++;
                        best->profile = 0;
                        best->builtinsprofile = 0;
index 0d2246e..499820c 100644 (file)
                                        PRVM_ERROR("NULL function in %s", PRVM_NAME);
 
                                newf = &prog->functions[OPA->function];
+                               newf->callcount++;
 
                                if (newf->first_statement < 0)
                                {