]> git.tdb.fi Git - libs/core.git/blob - source/debug/profilingscope.cpp
MSVC compatibility fixes
[libs/core.git] / source / debug / profilingscope.cpp
1 #include "../time/utils.h"
2 #include "profilingscope.h"
3
4 using namespace std;
5
6 namespace Msp {
7 namespace Debug {
8
9 ProfilingScope::ProfilingScope(Profiler &p, const string &n):
10         profiler(p),
11         name(n),
12         parent(profiler.enter(this)),
13         start_t(Time::now())
14 { }
15
16 ProfilingScope::~ProfilingScope()
17 {
18         const Time::TimeDelta dt=Time::now()-start_t;
19         if(parent)
20         {
21                 parent->child_t+=dt;
22                 profiler.record(name, parent->name, dt, child_t);
23         }
24         else
25                 profiler.record(name, string(), dt, child_t);
26         profiler.enter(parent);
27 }
28
29 } // namespace Debug
30 } // namespace Msp