diff options
author | Mike Buland <eichlan@xagasoft.com> | 2023-07-26 21:33:36 -0700 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2023-07-26 21:33:36 -0700 |
commit | e43a2cac32cb773994b11a3d964ec4acc372d273 (patch) | |
tree | 9e281be52f9dd8b80855c7d3cb9ec3df9cdd0ad3 /src/unstable/profiler.h | |
parent | b544779d5b759d4ab2b82654e3f53b82ea41bac7 (diff) | |
download | libbu++-e43a2cac32cb773994b11a3d964ec4acc372d273.tar.gz libbu++-e43a2cac32cb773994b11a3d964ec4acc372d273.tar.bz2 libbu++-e43a2cac32cb773994b11a3d964ec4acc372d273.tar.xz libbu++-e43a2cac32cb773994b11a3d964ec4acc372d273.zip |
Added a profiler and investageted Server.
Diffstat (limited to 'src/unstable/profiler.h')
-rw-r--r-- | src/unstable/profiler.h | 54 |
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 | |||
10 | namespace 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 | ||