patches to Ricardo Lopes' low level profiler: enable if SIGPROF is

there, do sorting, init PROFPREDS when you start counters, keep time
stamps for eventual assert/retract, and use qsort (3) to do less work.


git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@829 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc
2003-05-20 19:11:59 +00:00
parent d22fe2107c
commit 0afb07931f
14 changed files with 2736 additions and 1655 deletions

View File

@@ -2834,36 +2834,9 @@ Yap_cclause(Term inp_clause, int NOfArgs, int mod)
/* phase 3: assemble code */
acode = Yap_assemble(ASSEMBLING_CLAUSE);
#ifdef LOW_PROF
{
static int pred_count=0;
FILE *f,*init;
extern int PROFSIZE;
if (!pred_count++) {
f=fopen("PROFPREDS","w");
init=fopen("PROFINIT","r");
if (init!=NULL) {
size_t nc; char buffer[4100];
do {
nc=fread(buffer,1,4096,init);
fwrite(buffer,1,nc,f);
} while(nc>0);
fclose(init);
}
} else {
f=fopen("PROFPREDS","a");
}
if (f!=NULL) {
fprintf(f,"%x - %x - Pred(%ld) - %s/%d\n",acode,PROFSIZE, CodeStart->rnd1, RepAtom(AtomOfTerm(MkAtomTerm((Atom) CodeStart->rnd1)))->StrOfAE, CodeStart->rnd2);
fclose(f);
}
}
#endif
/* check first if there was space for us */
if (acode == NIL) {
if (acode == NULL) {
/* make sure we have enough space */
reset_vars();
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
@@ -2875,7 +2848,13 @@ Yap_cclause(Term inp_clause, int NOfArgs, int mod)
my_clause = Deref(ARG1);
goto restart_compilation;
}
} else
} else {
#ifdef LOW_PROF
if (ProfilerOn) {
Yap_inform_profiler_of_clause(acode, Yap_prof_end, CurrentPred);
}
#endif
return(acode);
}
}