X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdebug%2Fprofilingscope.cpp;fp=source%2Fdebug%2Fprofilingscope.cpp;h=f92749b214f588357c38baa22f53960973aa9fdd;hb=e7638f74d3e4869020a19dfa1cc700d52373f01c;hp=0000000000000000000000000000000000000000;hpb=c13c5d2e330e4cee177c1fd8e0b6153c7e2503e4;p=libs%2Fcore.git diff --git a/source/debug/profilingscope.cpp b/source/debug/profilingscope.cpp new file mode 100644 index 0000000..f92749b --- /dev/null +++ b/source/debug/profilingscope.cpp @@ -0,0 +1,30 @@ +#include "../time/utils.h" +#include "profilingscope.h" + +using namespace std; + +namespace Msp { +namespace Debug { + +ProfilingScope::ProfilingScope(Profiler &p, const string &n): + profiler(p), + name(n), + parent(profiler.enter(this)), + start_t(Time::now()) +{ } + +ProfilingScope::~ProfilingScope() +{ + const Time::TimeDelta dt=start_t-Time::now(); + if(parent) + { + parent->child_t+=dt; + profiler.record(name, parent->name, dt, child_t); + } + else + profiler.record(name, string(), dt, child_t); + profiler.enter(parent); +} + +} // namespace Debug +} // namespace Msp