From e43a2cac32cb773994b11a3d964ec4acc372d273 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 26 Jul 2023 21:33:36 -0700 Subject: Added a profiler and investageted Server. --- src/unstable/profiler.h | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/unstable/profiler.h (limited to 'src/unstable/profiler.h') 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 @@ +#ifndef BU_PROFILER_H +#define BU_PROFILER_H + +#include "bu/blob.h" +#include "bu/hash.h" +#include "bu/list.h" +#include "bu/mutex.h" +#include "bu/singleton.h" + +namespace Bu +{ + class Profiler : public Bu::Singleton + { + friend class Bu::Singleton; + private: + Profiler(); + virtual ~Profiler(); + + public: + static uint64_t getMicroTime(); + + void startEvent( const Bu::Blob &bName ); + void endEvent( const Bu::Blob &bName ); + + void printReport() const; + + private: + class Event + { + public: + Event(); + Event( const Event &rSrc ); + ~Event(); + + void end(); + bool hasEnded() const; + + uint64_t getStart() const; + uint64_t getEnd() const; + uint64_t getSpan() const; + + private: + uint64_t iStart; + uint64_t iStop; + }; + + typedef Bu::List EventList; + typedef Bu::Hash EventListHash; + EventListHash hEvent; + mutable Bu::Mutex mLock; + }; +}; + +#endif -- cgit v1.2.3