Chris@49: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@0: Chris@0: /* Chris@52: Sonic Visualiser Chris@52: An audio file viewer and annotation editor. Chris@52: Centre for Digital Music, Queen Mary, University of London. Chris@0: Chris@52: This program is free software; you can redistribute it and/or Chris@52: modify it under the terms of the GNU General Public License as Chris@52: published by the Free Software Foundation; either version 2 of the Chris@52: License, or (at your option) any later version. See the file Chris@52: COPYING included with this distribution for more information. 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@17: This file copyright 2000-2006 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