comparison base/Profiler.h @ 1365:3382d914e110

Merge from branch 3.0-integration
author Chris Cannam
date Fri, 13 Jan 2017 10:29:44 +0000
parents c811991a5efa
children ad5f892c0c4d
comparison
equal deleted inserted replaced
1272:6a7ea3bd0e10 1365:3382d914e110
23 #ifndef _PROFILER_H_ 23 #ifndef _PROFILER_H_
24 #define _PROFILER_H_ 24 #define _PROFILER_H_
25 25
26 #include "system/System.h" 26 #include "system/System.h"
27 27
28 #include <ctime>
29 #include <sys/time.h>
30 #include <map> 28 #include <map>
31 29
32 #include "RealTime.h" 30 #include "RealTime.h"
33 31
34 //#define NO_TIMING 1 32 //#define NO_TIMING 1
37 35
38 #ifdef NDEBUG 36 #ifdef NDEBUG
39 #ifndef WANT_TIMING 37 #ifndef WANT_TIMING
40 #define NO_TIMING 1 38 #define NO_TIMING 1
41 #endif 39 #endif
40 #endif
41
42 #ifndef NO_TIMING
43 #include <ctime>
44 #include <sys/time.h>
42 #endif 45 #endif
43 46
44 /** 47 /**
45 * Profiling classes 48 * Profiling classes
46 */ 49 */
54 { 57 {
55 public: 58 public:
56 static Profiles* getInstance(); 59 static Profiles* getInstance();
57 ~Profiles(); 60 ~Profiles();
58 61
62 #ifndef NO_TIMING
59 void accumulate(const char* id, clock_t time, RealTime rt); 63 void accumulate(const char* id, clock_t time, RealTime rt);
64 #endif
60 void dump() const; 65 void dump() const;
61 66
62 protected: 67 protected:
63 Profiles(); 68 Profiles();
64 69
70 #ifndef NO_TIMING
65 typedef std::pair<clock_t, RealTime> TimePair; 71 typedef std::pair<clock_t, RealTime> TimePair;
66 typedef std::pair<int, TimePair> ProfilePair; 72 typedef std::pair<int, TimePair> ProfilePair;
67 typedef std::map<const char *, ProfilePair> ProfileMap; 73 typedef std::map<const char *, ProfilePair> ProfileMap;
68 typedef std::map<const char *, TimePair> LastCallMap; 74 typedef std::map<const char *, TimePair> LastCallMap;
69 typedef std::map<const char *, TimePair> WorstCallMap; 75 typedef std::map<const char *, TimePair> WorstCallMap;
70 ProfileMap m_profiles; 76 ProfileMap m_profiles;
71 LastCallMap m_lastCalls; 77 LastCallMap m_lastCalls;
72 WorstCallMap m_worstCalls; 78 WorstCallMap m_worstCalls;
79 #endif
73 80
74 static Profiles* m_instance; 81 static Profiles* m_instance;
75 }; 82 };
76 83
77 #ifndef NO_TIMING 84 #ifndef NO_TIMING