--- /dev/null
+#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