27ProfileTimer(
const char* name,
int maxEntries) :
34 init(name, maxEntries);
45 _maxEntries=other._maxEntries;
47 init(_name, _maxEntries);
51 _elapsedTime=other._elapsedTime;
52 _autoTimerCount=other._autoTimerCount;
53 _entryCount=other._entryCount;
55 memcpy(_entries, other._entries, _entryCount *
sizeof(TimerEntry));
61 PANDA_FREE_ARRAY(_entries);
80init(
const char* name,
int maxEntries) {
82 _maxEntries=maxEntries;
83 _entries = (TimerEntry *)PANDA_MALLOC_ARRAY(_maxEntries *
sizeof(TimerEntry));
93 for (i=0; i<_entryCount; ++i) {
94 TimerEntry& te=_entries[i];
101consolidateAllTo(ostream &out) {
104 p->consolidateTo(out);
110consolidateTo(ostream &out)
const {
113 for (i=0; i<_entryCount; ++i) {
114 TimerEntry& te=_entries[i];
115 entries[te._tag]+=te._time;
117 out <<
"-------------------------------------------------------------------\n"
118 <<
"Profile Timing of " << _name
123 for (;i!=entries.end(); ++i) {
124 out <<
" " << std::setw(50) << i->first <<
": "
125 << std::setiosflags(std::ios::fixed) << std::setprecision(6) << std::setw(10) << i->second <<
"\n";
129 out <<
"\n [Total Time: "
130 << std::setiosflags(std::ios::fixed) << std::setprecision(6) << total
132 <<
"-------------------------------------------------------------------\n";
137printAllTo(ostream &out) {
146printTo(ostream &out)
const {
147 out <<
"-------------------------------------------------------------------\n"
148 <<
"Profile Timing of " << _name
152 for (i=0; i<_entryCount; ++i) {
153 TimerEntry& te=_entries[i];
154 out <<
" " << std::setw(50) << te._tag <<
": "
155 << std::setiosflags(std::ios::fixed) << std::setprecision(6) << std::setw(10) << te._time <<
"\n";
158 out <<
"\n [Total Time: "
159 << std::setiosflags(std::ios::fixed) << std::setprecision(6) << total
161 <<
"-------------------------------------------------------------------\n";
165ProfileTimer::AutoTimer::AutoTimer(
ProfileTimer& profile,
const char* tag) :
168 if (_profile._autoTimerCount) {
171 _profile.mark(_profile._entries[_profile._entryCount-1]._tag);
174 _profile.mark(
"other");
177 ++_profile._autoTimerCount;
This is our own Panda specialization on the default STL map.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.