comparison base/Profiler.h @ 0:da6937383da8

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