]> git.tdb.fi Git - libs/core.git/blob - source/debug/profilingscope.h
Add move semantics to Variant
[libs/core.git] / source / debug / profilingscope.h
1 #ifndef MSP_DEBUG_PROFILINGSCOPE_H_
2 #define MSP_DEBUG_PROFILINGSCOPE_H_
3
4 #include <msp/core/mspcore_api.h>
5 #include <msp/core/noncopyable.h>
6 #include <msp/time/timestamp.h>
7 #include "profiler.h"
8
9 namespace Msp {
10 namespace Debug {
11
12 /**
13 RAII timing class to accompany Profiler.  Timing starts when an object is
14 created and ends when it goes out of scope.  If there was another object in an
15 outer scope, it is notified of the time used in inner scopes.
16 */
17 class MSPCORE_API ProfilingScope: private NonCopyable
18 {
19 private:
20         Profiler &profiler;
21         std::string name;
22         ProfilingScope *parent = nullptr;
23         Time::TimeStamp entry_time;
24         Time::TimeDelta time_spent;
25         Time::TimeDelta child_time;
26
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