]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - prvm_exec.c
improved plane distance epsilon checking and improved precision when converting brush...
[xonotic/darkplaces.git] / prvm_exec.c
index eb8aa349718b224f67b5690f864706c2df9b0a9a..eab6a2fdf2e51d2d9851dafd376d47b96bd6f926 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]))
        {
@@ -266,29 +266,11 @@ void PRVM_StackTrace (void)
 }
 
 
-/*
-============
-PRVM_Profile_f
-
-============
-*/
-void PRVM_Profile_f (void)
+void PRVM_Profile (int maxfunctions, int mininstructions)
 {
        mfunction_t *f, *best;
-       int i, num, max/*, howmany*/;
-
-       //howmany = 10;
-       //if (Cmd_Argc() == 2)
-       //      howmany = atoi(Cmd_Argv(1));
-       if(Cmd_Argc() != 2)
-       {
-               Con_Print("prvm_profile <program name>\n");
-               return;
-       }
-
-       PRVM_Begin;
-       if(!PRVM_SetProgFromString(Cmd_Argv(1)))
-               return;
+       int i, num;
+       double max;
 
        Con_Printf( "%s Profile:\n[CallCount] [Statements] [BuiltinCost]\n", PRVM_NAME );
 
@@ -308,17 +290,45 @@ 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 < maxfunctions && max >= mininstructions)
+                       {
+                               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;
                        best->callcount = 0;
                }
        } while (best);
+}
+
+/*
+============
+PRVM_Profile_f
+
+============
+*/
+void PRVM_Profile_f (void)
+{
+       int howmany;
+
+       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;
+       }
+
+       PRVM_Begin;
+       if(!PRVM_SetProgFromString(Cmd_Argv(1)))
+               return;
+
+       PRVM_Profile(howmany, 1);
 
        PRVM_End;
 }