aboutsummaryrefslogtreecommitdiff
path: root/src/unstable/profiler.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/unstable/profiler.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/unstable/profiler.h b/src/unstable/profiler.h
new file mode 100644
index 0000000..df05023
--- /dev/null
+++ b/src/unstable/profiler.h
@@ -0,0 +1,54 @@
1#ifndef BU_PROFILER_H
2#define BU_PROFILER_H
3
4#include "bu/blob.h"
5#include "bu/hash.h"
6#include "bu/list.h"
7#include "bu/mutex.h"
8#include "bu/singleton.h"
9
10namespace Bu
11{
12 class Profiler : public Bu::Singleton<Profiler>
13 {
14 friend class Bu::Singleton<Profiler>;
15 private:
16 Profiler();
17 virtual ~Profiler();
18
19 public:
20 static uint64_t getMicroTime();
21
22 void startEvent( const Bu::Blob &bName );
23 void endEvent( const Bu::Blob &bName );
24
25 void printReport() const;
26
27 private:
28 class Event
29 {
30 public:
31 Event();
32 Event( const Event &rSrc );
33 ~Event();
34
35 void end();
36 bool hasEnded() const;
37
38 uint64_t getStart() const;
39 uint64_t getEnd() const;
40 uint64_t getSpan() const;
41
42 private:
43 uint64_t iStart;
44 uint64_t iStop;
45 };
46
47 typedef Bu::List<Event> EventList;
48 typedef Bu::Hash<Bu::Blob, EventList> EventListHash;
49 EventListHash hEvent;
50 mutable Bu::Mutex mLock;
51 };
52};
53
54#endif