Chris@0: /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */ Chris@0: Chris@0: /* Chris@0: A waveform viewer and audio annotation editor. Chris@2: Chris Cannam, Queen Mary University of London, 2005-2006 Chris@0: Chris@0: This is experimental software. Not for distribution. Chris@0: */ Chris@0: Chris@0: /* Chris@0: This is a modified version of a source file from the Chris@0: Rosegarden MIDI and audio sequencer and notation editor. Chris@0: This file copyright 2000-2005 Chris Cannam and Guillaume Laurent. Chris@0: */ Chris@0: Chris@0: Chris@0: #ifndef _PROFILER_H_ Chris@0: #define _PROFILER_H_ Chris@0: Chris@0: #include "System.h" Chris@0: Chris@0: #include Chris@0: #include Chris@0: #include Chris@0: Chris@0: #include "RealTime.h" Chris@0: Chris@0: Chris@0: /** Chris@0: * Profiling classes Chris@0: */ Chris@0: Chris@0: /** Chris@0: * The class holding all profiling data Chris@0: * Chris@0: * This class is a singleton Chris@0: */ Chris@0: class Profiles Chris@0: { Chris@0: public: Chris@0: static Profiles* getInstance(); Chris@0: ~Profiles(); Chris@0: Chris@0: void accumulate(const char* id, clock_t time, RealTime rt); Chris@0: void dump(); Chris@0: Chris@0: protected: Chris@0: Profiles(); Chris@0: Chris@0: typedef std::pair TimePair; Chris@0: typedef std::pair ProfilePair; Chris@0: typedef std::map ProfileMap; Chris@0: typedef std::map LastCallMap; Chris@0: ProfileMap m_profiles; Chris@0: LastCallMap m_lastCalls; Chris@0: Chris@0: static Profiles* m_instance; Chris@0: }; Chris@0: Chris@0: class Profiler Chris@0: { Chris@0: public: Chris@0: Profiler(const char*, bool showOnDestruct = false); Chris@0: ~Profiler(); Chris@0: Chris@0: void update(); Chris@0: Chris@0: protected: Chris@0: const char* m_c; Chris@0: clock_t m_startCPU; Chris@0: RealTime m_startTime; Chris@0: bool m_showOnDestruct; Chris@0: }; Chris@0: Chris@0: Chris@0: #endif