statistics info

This commit is contained in:
Vítor Santos Costa 2013-01-23 09:58:02 +00:00
parent 2de1a678e4
commit 3c021a41cf
3 changed files with 45 additions and 8 deletions

View File

@ -5416,27 +5416,55 @@ Yap_dump_code_area_for_profiler(void) {
#endif /* LOW_PROF */
static UInt
index_ssz(StaticIndex *x)
tree_index_ssz(StaticIndex *x)
{
UInt sz = x->ClSize;
x = x->ChildIndex;
while (x != NULL) {
sz += index_ssz(x);
sz += tree_index_ssz(x);
x = x->SiblingIndex;
}
return sz;
}
static UInt
index_ssz(StaticIndex *x, PredEntry *pe)
{
UInt sz = 0;
yamop *ep = ExpandClausesFirst;
if (pe->PredFlags & MegaClausePredFlag) {
MegaClause *mcl = ClauseCodeToMegaClause(pe->cs.p_code.FirstClause);
if (mcl->ClFlags & ExoMask) {
struct index_t *i = ((struct index_t **)(pe->cs.p_code.FirstClause))[0];
sz = 0;
while (i) {
sz = i->size+sz;
}
return sz;
}
}
/* expand clause blocks */
while (ep) {
if (ep->u.sssllp.p == pe)
sz += (UInt)NEXTOP((yamop *)NULL,sssllp)+ep->u.sssllp.s1*sizeof(yamop *);
ep = ep->u.sssllp.snext;
}
/* main indexing tree */
sz += tree_index_ssz(x);
return sz;
}
static Int
static_statistics(PredEntry *pe)
{
CACHE_REGS
UInt sz = 0, cls = 0, isz = 0;
UInt sz = sizeof(PredEntry), cls = 0, isz = 0;
StaticClause *cl = ClauseCodeToStaticClause(pe->cs.p_code.FirstClause);
if (pe->cs.p_code.NOfClauses > 1 &&
pe->cs.p_code.TrueCodeOfPred != pe->cs.p_code.FirstClause) {
isz = index_ssz(ClauseCodeToStaticIndex(pe->cs.p_code.TrueCodeOfPred));
isz = index_ssz(ClauseCodeToStaticIndex(pe->cs.p_code.TrueCodeOfPred), pe);
}
if (pe->PredFlags & MegaClausePredFlag) {
MegaClause *mcl = ClauseCodeToMegaClause(pe->cs.p_code.FirstClause);

View File

@ -3749,7 +3749,7 @@ index_sz(LogUpdIndex *x)
static Int
lu_statistics(PredEntry *pe USES_REGS)
{
UInt sz = 0, cls = 0, isz = 0;
UInt sz = sizeof(PredEntry), cls = 0, isz = 0;
/* count number of clauses and size */
LogUpdClause *x;
@ -3765,10 +3765,16 @@ lu_statistics(PredEntry *pe USES_REGS)
x = x->ClNext;
}
}
isz = 0;
if (pe->PredFlags & IndexedPredFlag) {
isz = index_sz(ClauseCodeToLogUpdIndex(pe->cs.p_code.TrueCodeOfPred));
} else {
isz = 0;
/* expand clause blocks */
yamop *ep = ExpandClausesFirst;
while (ep) {
if (ep->u.sssllp.p == pe)
isz += (UInt)NEXTOP((yamop *)NULL,sssllp)+ep->u.sssllp.s1*sizeof(yamop *);
ep = ep->u.sssllp.snext;
}
isz += index_sz(ClauseCodeToLogUpdIndex(pe->cs.p_code.TrueCodeOfPred));
}
return
Yap_unify(ARG2,MkIntegerTerm(cls)) &&

View File

@ -230,6 +230,7 @@ fill_hash(UInt bmap, struct index_t *it, UInt bnds[])
static struct index_t *
add_index(struct index_t **ip, UInt bmap, PredEntry *ap, UInt count, UInt bnds[])
{
CACHE_REGS
UInt ncls = ap->cs.p_code.NOfClauses, j;
CELL *base = NULL;
struct index_t *i;
@ -265,6 +266,7 @@ add_index(struct index_t **ip, UInt bmap, PredEntry *ap, UInt count, UInt bnds[]
}
bzero(base, 3*sizeof(CELL)*ncls);
}
i->size = sizeof(CELL)*(ncls+i->hsize)+sz+sizeof(struct index_t);
i->key = (CELL **)base;
i->links = (CELL *)(base+i->hsize);
i->ncollisions = i->nentries = i->ntrys = 0;
@ -309,6 +311,7 @@ add_index(struct index_t **ip, UInt bmap, PredEntry *ap, UInt count, UInt bnds[]
ptr = NEXTOP(ptr, p);
ptr->opc = Yap_opcode(_Ystop);
ptr->u.l.l = i->code;
Yap_inform_profiler_of_clause((char *)(i->code), (char *)NEXTOP(ptr,l), ap, GPROF_INDEX);
return i;
}