]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - prvm_exec.c
Replaced all calls to str[n]cat and strncpy by calls to strlcat and strlcpy respectively
[xonotic/darkplaces.git] / prvm_exec.c
index e7fb591a04550789d74c5e709c6d699aa842d70b..eab6a2fdf2e51d2d9851dafd376d47b96bd6f926 100644 (file)
@@ -266,31 +266,12 @@ 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, howmany;
+       int i, num;
        double max;
 
-       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;
-
        Con_Printf( "%s Profile:\n[CallCount] [Statements] [BuiltinCost]\n", PRVM_NAME );
 
        num = 0;
@@ -309,7 +290,7 @@ void PRVM_Profile_f (void)
                }
                if (best)
                {
-                       if (num < howmany)
+                       if (num < maxfunctions && max >= mininstructions)
                        {
                                if (best->first_statement < 0)
                                        Con_Printf("%9.0f ----- builtin ----- %s\n", best->callcount, PRVM_GetString(best->s_name));
@@ -322,6 +303,32 @@ void PRVM_Profile_f (void)
                        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;
 }