From 8ba95d27a44c667568ae9a5aa1b4b69d75a9d565 Mon Sep 17 00:00:00 2001 From: black Date: Fri, 20 May 2005 19:20:39 +0000 Subject: [PATCH] -Added the callcount field to the mfunction_t structure. -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 | 1 + pr_exec.c | 4 +++- pr_execprogram.h | 1 + prvm_exec.c | 6 ++++-- prvm_execprogram.h | 1 + 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pr_comp.h b/pr_comp.h index 7a744645..46fdc6b7 100644 --- 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 diff --git a/pr_exec.c b/pr_exec.c index c516fec7..2393ed1d 100644 --- 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; diff --git a/pr_execprogram.h b/pr_execprogram.h index 5089e275..3ea2241e 100644 --- a/pr_execprogram.h +++ b/pr_execprogram.h @@ -272,6 +272,7 @@ Host_Error("Bad function number"); newf = &pr_functions[OPA->function]; + newf->callcount++; if (newf->first_statement < 0) { diff --git a/prvm_exec.c b/prvm_exec.c index 47ab9089..428a1586 100644 --- a/prvm_exec.c +++ b/prvm_exec.c @@ -199,11 +199,13 @@ void PRVM_Profile_f (void) Con_Print("prvm_profile \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; diff --git a/prvm_execprogram.h b/prvm_execprogram.h index 0d2246ec..499820ce 100644 --- a/prvm_execprogram.h +++ b/prvm_execprogram.h @@ -270,6 +270,7 @@ PRVM_ERROR("NULL function in %s", PRVM_NAME); newf = &prog->functions[OPA->function]; + newf->callcount++; if (newf->first_statement < 0) { -- 2.39.2