void _PRVM_Free (void *buffer, const char *filename, int fileline);
void _PRVM_FreeAll (const char *filename, int fileline);
+void PRVM_Profile (int maxfunctions, int mininstructions);
void PRVM_Profile_f (void);
void PRVM_PrintFunction_f (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;
}
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));
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;
}
if (++jumpcount == 10000000)
{
prog->xstatement = st - prog->statements;
- PRVM_ERROR("runaway loop counter hit limit of %d jumps\ntip: if having trouble identifying the problem, try typing profile now in %s", jumpcount, PRVM_NAME);
+ PRVM_Profile(1<<30, 1000000);
+ PRVM_ERROR("runaway loop counter hit limit of %d jumps\ntip: read above for list of most-executed functions", jumpcount, PRVM_NAME);
}
}
break;
if (++jumpcount == 10000000)
{
prog->xstatement = st - prog->statements;
- PRVM_ERROR("runaway loop counter hit limit of %d jumps\ntip: if having trouble identifying the problem, try typing profile now in %s", jumpcount, PRVM_NAME);
+ PRVM_Profile(1<<30, 1000000);
+ PRVM_ERROR("runaway loop counter hit limit of %d jumps\ntip: read above for list of most-executed functions", jumpcount, PRVM_NAME);
}
}
break;
if (++jumpcount == 10000000)
{
prog->xstatement = st - prog->statements;
- PRVM_ERROR("runaway loop counter hit limit of %d jumps\ntip: if having trouble identifying the problem, try typing profile now in %s", jumpcount, PRVM_NAME);
+ PRVM_Profile(1<<30, 1000000);
+ PRVM_ERROR("runaway loop counter hit limit of %d jumps\ntip: read above for list of most-executed functions", jumpcount, PRVM_NAME);
}
break;