00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef PROFILETIMER_H //[
00019 #define PROFILETIMER_H
00020
00021 #include "pandabase.h"
00022 #include "trueClock.h"
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 class EXPCL_PANDAEXPRESS ProfileTimer {
00046 enum { MaxEntriesDefault=4096 };
00047 PUBLISHED:
00048 ProfileTimer(const char* name=0, int maxEntries=MaxEntriesDefault);
00049 ProfileTimer(const ProfileTimer& other);
00050 ~ProfileTimer();
00051
00052 void init(const char* name, int maxEntries=MaxEntriesDefault);
00053
00054 void on();
00055 void mark(const char* tag);
00056 void off();
00057 void off(const char* tag);
00058
00059
00060
00061 double getTotalTime() const;
00062 static void consolidateAllTo(ostream &out=cout);
00063 void consolidateTo(ostream &out=cout) const;
00064 static void printAllTo(ostream &out=cout);
00065 void printTo(ostream &out=cout) const;
00066
00067 public:
00068
00069
00070
00071
00072
00073
00074
00075 class EXPCL_PANDAEXPRESS AutoTimer {
00076 public:
00077 AutoTimer(ProfileTimer& profile, const char* tag);
00078 ~AutoTimer();
00079
00080 protected:
00081 ProfileTimer& _profile;
00082 const char* _tag;
00083 };
00084
00085 protected:
00086 static ProfileTimer* _head;
00087 ProfileTimer* _next;
00088 class TimerEntry {
00089 public:
00090 const char* _tag;
00091 double _time;
00092 };
00093 double _on;
00094 double _elapsedTime;
00095 const char* _name;
00096 int _maxEntries;
00097 int _entryCount;
00098 TimerEntry* _entries;
00099 int _autoTimerCount;
00100
00101 double getTime();
00102
00103 friend class ProfileTimer::AutoTimer;
00104 };
00105
00106 #include "profileTimer.I"
00107
00108 #endif //]