]> git.tdb.fi Git - libs/core.git/blob - source/debug/profilingscope.h
Clean up after the timedelta.h/units.h merge
[libs/core.git] / source / debug / profilingscope.h
1 #ifndef MSP_DEBUG_PROFILINGSCOPE_H_
2 #define MSP_DEBUG_PROFILINGSCOPE_H_
3
4 #include <msp/time/timestamp.h>
5 #include "profiler.h"
6
7 namespace Msp {
8 namespace Debug {
9
10 /**
11 RAII timing class to accompany Profiler.  Timing starts when an object is
12 created and ends when it goes out of scope.  If there was another object in an
13 outer scope, it is notified of the time used in inner scopes.
14 */
15 class ProfilingScope
16 {
17 private:
18         Profiler &profiler;
19         std::string name;
20         ProfilingScope *parent;
21         Time::TimeStamp entry_time;
22         Time::TimeDelta time_spent;
23         Time::TimeDelta child_time;
24
25         ProfilingScope(const ProfilingScope &);
26         ProfilingScope &operator=(const ProfilingScope &);
27 public:
28         ProfilingScope(Profiler &p, const std::string &n);
29         ~ProfilingScope();
30
31         const std::string &get_name() const { return name; }
32         const ProfilingScope *get_parent() const { return parent; }
33         const Time::TimeStamp &get_entry_time() const { return entry_time; }
34         const Time::TimeDelta &get_time_spent() const { return time_spent; }
35         const Time::TimeDelta &get_child_time() const { return child_time; }
36 };
37
38 } // namespace Debug
39 } // namespace Msp
40
41 #endif