[gamecode] Get PR_Profile working

The switch from using pr_functions (dfunction_t) to function_table
(bfunction_t) for keeping track of the current function (and thus
profiling data) broke PR_Profile as it never saw anything but 0.
This commit is contained in:
Bill Currie 2021-12-27 13:50:49 +09:00
parent 6368791d2b
commit cafc6a541f
2 changed files with 11 additions and 8 deletions

View file

@ -1196,7 +1196,7 @@ typedef struct {
pr_int_t first_statement;
pr_int_t parm_start;
pr_int_t locals;
pr_int_t profile;
pr_uint_t profile;
pr_int_t numparms;
dparmsize_t parm_size[MAX_PARMS];
dfunction_t *descriptor;

View file

@ -1712,23 +1712,26 @@ VISIBLE void
PR_Profile (progs_t * pr)
{
pr_uint_t max, num, i;
dfunction_t *best, *f;
dfunction_t *f;
bfunction_t *best, *bf;
num = 0;
do {
max = 0;
best = NULL;
for (i = 0; i < pr->progs->numfunctions; i++) {
f = &pr->pr_functions[i];
if (f->profile > max) {
max = f->profile;
best = f;
bf = &pr->function_table[i];
if (bf->profile > max) {
max = bf->profile;
best = bf;
}
}
if (best) {
if (num < 10)
if (num < 10) {
f = pr->pr_functions + (best - pr->function_table);
Sys_Printf ("%7i %s\n", best->profile,
PR_GetString (pr, best->s_name));
PR_GetString (pr, f->s_name));
}
num++;
best->profile = 0;
}