From: Gonzalo A. <ga...@us...> - 2006-10-05 15:28:44
|
Update of /cvsroot/mod-c/ehtml/src In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv26208/src Modified Files: Profiling.cpp Log Message: * Fixed profiling 'self' counter. Index: Profiling.cpp =================================================================== RCS file: /cvsroot/mod-c/ehtml/src/Profiling.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Profiling.cpp 13 Sep 2006 14:59:50 -0000 1.3 --- Profiling.cpp 5 Oct 2006 15:28:36 -0000 1.4 *************** *** 4,17 **** #include <string.h> ProfileFunction* ProfileFunction::_head = NULL; int ProfileRun::depth = 0; ProfileFunction* ProfileRun::call_stack[MAX_DEPTH] = { NULL, }; ProfileRun::~ProfileRun() { hrtime_t diff = get_tick() - _started; _f->spec.accum += diff; _f->spec.self += diff; ! if (depth) ! call_stack[--depth]->spec.self -= diff; ++_f->spec.ncalls; } --- 4,25 ---- #include <string.h> + #include <assert.h> + ProfileFunction* ProfileFunction::_head = NULL; int ProfileRun::depth = 0; ProfileFunction* ProfileRun::call_stack[MAX_DEPTH] = { NULL, }; + ProfileRun::ProfileRun(ProfileFunction* f): _started(get_tick()), _f(f) { + call_stack[depth++] = f; + } + ProfileRun::~ProfileRun() { + assert(depth > 0); + --depth; hrtime_t diff = get_tick() - _started; _f->spec.accum += diff; _f->spec.self += diff; ! if (depth > 0) ! call_stack[depth-1]->spec.self -= diff; ++_f->spec.ncalls; } |