Пример #1
0
static void
Stop(ProfilerObject *pObj, ProfilerContext *self, ProfilerEntry *entry)
{
	PY_LONG_LONG tt = CALL_TIMER(pObj) - self->t0;
	PY_LONG_LONG it = tt - self->subt;
	if (self->previous)
		self->previous->subt += tt;
	pObj->currentProfilerContext = self->previous;
	if (--entry->recursionLevel == 0)
		entry->tt += tt;
	else
		++entry->recursivecallcount;
	entry->it += it;
	entry->callcount++;
	if ((pObj->flags & POF_SUBCALLS) && self->previous) {
		/* find or create an entry for me in my caller's entry */
		ProfilerEntry *caller = self->previous->ctxEntry;
		ProfilerSubEntry *subentry = getSubEntry(pObj, caller, entry);
		if (subentry) {
			if (--subentry->recursionLevel == 0)
				subentry->tt += tt;
			else
				++subentry->recursivecallcount;
			subentry->it += it;
			++subentry->callcount;
		}
	}
}
Пример #2
0
static void
initContext(ProfilerObject *pObj, ProfilerContext *self, ProfilerEntry *entry)
{
	self->ctxEntry = entry;
	self->subt = 0;
	self->previous = pObj->currentProfilerContext;
	pObj->currentProfilerContext = self;
	++entry->recursionLevel;
	if ((pObj->flags & POF_SUBCALLS) && self->previous) {
		/* find or create an entry for me in my caller's entry */
		ProfilerEntry *caller = self->previous->ctxEntry;
		ProfilerSubEntry *subentry = getSubEntry(pObj, caller, entry);
		if (subentry == NULL)
			subentry = newSubEntry(pObj, caller, entry);
		if (subentry)
			++subentry->recursionLevel;
	}
	self->t0 = CALL_TIMER(pObj);
}
Пример #3
0
static void
initContext(ProfilerObject *pObj, ProfilerContext *self, ProfilerEntry *entry)
{
    long subcallRecursionLevel = 0;
    self->ctxEntry = entry;
    self->subt = self->paused = 0;
    self->previous = CURRENT_CONTEXT(pObj);
    CURRENT_CONTEXT(pObj) = self;
    ++entry->recursionLevel;
    if ((pObj->flags & POF_SUBCALLS) && self->previous) {
        /* find or create an entry for me in my caller's entry */
        ProfilerEntry *caller = self->previous->ctxEntry;
        ProfilerSubEntry *subentry = getSubEntry(pObj, caller, entry);
        if (subentry == NULL)
            subentry = newSubEntry(pObj, caller, entry);
        if (subentry)
            subcallRecursionLevel = ++subentry->recursionLevel;
    }
    checkRecursion(self, pObj->nProfilerStacks, entry->recursionLevel,
                   subcallRecursionLevel);
    self->t0 = pObj->currentTime;
}
Пример #4
0
static void
Stop(ProfilerObject *pObj, ProfilerContext *self, ProfilerEntry *entry)
{
    PY_LONG_LONG tt, it;

    tt = pObj->currentTime - self->t0;
    tt -= self->paused;
    it = tt - self->subt;

    if (self->previous) {
        self->previous->subt += tt;
        self->previous->paused += self->paused;
    }
    CURRENT_CONTEXT(pObj) = self->previous;
    --entry->recursionLevel;
    if (!self->is_recursion)
        entry->tt += tt;
    else
        ++entry->recursivecallcount;
    entry->it += it;
    entry->callcount++;
    if ((pObj->flags & POF_SUBCALLS) && self->previous) {
        /* find or create an entry for me in my caller's entry */
        ProfilerEntry *caller = self->previous->ctxEntry;
        ProfilerSubEntry *subentry = getSubEntry(pObj, caller, entry);
        if (subentry) {
            --subentry->recursionLevel;
            if (!self->is_subcall_recursion)
                subentry->tt += tt;
            else
                ++subentry->recursivecallcount;
            subentry->it += it;
            ++subentry->callcount;
        }
    }
}