annotate base/Profiler.h @ 7:49a95b174050

* Add more icons and rationalise menu options to the usual set (on the File menu) * Fixes to import/export of dense 3-D data sets and imported models
author Chris Cannam
date Thu, 19 Jan 2006 17:59:11 +0000
parents d86891498eef
children 2fb933f88604
rev   line source
Chris@0 1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */
Chris@0 2
Chris@0 3 /*
Chris@0 4 A waveform viewer and audio annotation editor.
Chris@2 5 Chris Cannam, Queen Mary University of London, 2005-2006
Chris@0 6
Chris@0 7 This is experimental software. Not for distribution.
Chris@0 8 */
Chris@0 9
Chris@0 10 /*
Chris@0 11 This is a modified version of a source file from the
Chris@0 12 Rosegarden MIDI and audio sequencer and notation editor.
Chris@0 13 This file copyright 2000-2005 Chris Cannam and Guillaume Laurent.
Chris@0 14 */
Chris@0 15
Chris@0 16
Chris@0 17 #ifndef _PROFILER_H_
Chris@0 18 #define _PROFILER_H_
Chris@0 19
Chris@0 20 #include "System.h"
Chris@0 21
Chris@0 22 #include <ctime>
Chris@0 23 #include <sys/time.h>
Chris@0 24 #include <map>
Chris@0 25
Chris@0 26 #include "RealTime.h"
Chris@0 27
Chris@0 28
Chris@0 29 /**
Chris@0 30 * Profiling classes
Chris@0 31 */
Chris@0 32
Chris@0 33 /**
Chris@0 34 * The class holding all profiling data
Chris@0 35 *
Chris@0 36 * This class is a singleton
Chris@0 37 */
Chris@0 38 class Profiles
Chris@0 39 {
Chris@0 40 public:
Chris@0 41 static Profiles* getInstance();
Chris@0 42 ~Profiles();
Chris@0 43
Chris@0 44 void accumulate(const char* id, clock_t time, RealTime rt);
Chris@0 45 void dump();
Chris@0 46
Chris@0 47 protected:
Chris@0 48 Profiles();
Chris@0 49
Chris@0 50 typedef std::pair<clock_t, RealTime> TimePair;
Chris@0 51 typedef std::pair<int, TimePair> ProfilePair;
Chris@0 52 typedef std::map<const char *, ProfilePair> ProfileMap;
Chris@0 53 typedef std::map<const char *, TimePair> LastCallMap;
Chris@0 54 ProfileMap m_profiles;
Chris@0 55 LastCallMap m_lastCalls;
Chris@0 56
Chris@0 57 static Profiles* m_instance;
Chris@0 58 };
Chris@0 59
Chris@0 60 class Profiler
Chris@0 61 {
Chris@0 62 public:
Chris@0 63 Profiler(const char*, bool showOnDestruct = false);
Chris@0 64 ~Profiler();
Chris@0 65
Chris@0 66 void update();
Chris@0 67
Chris@0 68 protected:
Chris@0 69 const char* m_c;
Chris@0 70 clock_t m_startCPU;
Chris@0 71 RealTime m_startTime;
Chris@0 72 bool m_showOnDestruct;
Chris@0 73 };
Chris@0 74
Chris@0 75
Chris@0 76 #endif