]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
-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 7a744645669fa785d49d721c059f4f07587eda88..46fdc6b70c624aeee86ec6655a6f1ce0dd63ada1 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 c516fec7f2e6820ac648d3806252a1bb77016851..2393ed1dd4d127d0939f31cee067f20e589cd555 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 5089e27577f3edf0de80852fb0f58db309171446..3ea2241ebb880f7016fdf149158d8ace205570b9 100644 (file)
                                        Host_Error("Bad function number");
 
                                newf = &pr_functions[OPA->function];
+                               newf->callcount++;
 
                                if (newf->first_statement < 0)
                                {
index 47ab908973b5058bde5b1b3f8e0e25963a05d6d0..428a1586af58e269fa2e7725aaa1db12c7f8786f 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 0d2246ecefa70c435e502ce137537a067b02320d..499820ce079d5b31db4d435e705678b8bab756c2 100644 (file)
                                        PRVM_ERROR("NULL function in %s", PRVM_NAME);
 
                                newf = &prog->functions[OPA->function];
+                               newf->callcount++;
 
                                if (newf->first_statement < 0)
                                {