]> git.tdb.fi Git - libs/core.git/blob - source/debug/profilingscope.h
132c4183bf883e2353e665c38ced3e00e5449e7d
[libs/core.git] / source / debug / profilingscope.h
1 /* $Id$
2
3 This file is part of libmspcore
4 Copyright © 2007  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_DEBUG_PROFILINGSCOPE_H_
9 #define MSP_DEBUG_PROFILINGSCOPE_H_
10
11 #include "../time/timestamp.h"
12 #include "profiler.h"
13
14 namespace Msp {
15 namespace Debug {
16
17 /**
18 RAII timing class to accompany Profiler.  Timing starts when an object is
19 created and ends when it goes out of scope.  If there was another object in an
20 outer scope, it is notified of the time used in inner scopes.
21 */
22 class ProfilingScope
23 {
24 private:
25         Profiler &profiler;
26         std::string name;
27         ProfilingScope *parent;
28         Time::TimeStamp start_t;
29         Time::TimeDelta child_t;
30
31         ProfilingScope(const ProfilingScope &);
32         ProfilingScope &operator=(const ProfilingScope &);
33 public:
34         ProfilingScope(Profiler &p, const std::string &n);
35         ~ProfilingScope();
36 };
37
38 } // namespace Debug
39 } // namespace Msp
40
41 #endif