Remove unused ProfileTimer class

It doesn't seem to be used by anything, but it does take up 64+ KiB of memory in every Panda process.
This commit is contained in:
rdb 2019-03-10 19:20:43 +01:00
parent 148134284d
commit a7d9baeeb8
6 changed files with 0 additions and 354 deletions

View File

@ -2206,7 +2206,6 @@
<File RelativePath="..\panda\src\express\typedReferenceCount.h"></File>
<File RelativePath="..\panda\src\express\virtualFileMountSystem.I"></File>
<File RelativePath="..\panda\src\express\nodePointerTo.I"></File>
<File RelativePath="..\panda\src\express\profileTimer.I"></File>
<File RelativePath="..\panda\src\express\hashVal.I"></File>
<File RelativePath="..\panda\src\express\pta_float.cxx"></File>
<File RelativePath="..\panda\src\express\weakPointerTo.h"></File>
@ -2215,10 +2214,8 @@
<File RelativePath="..\panda\src\express\pointerToArrayBase.I"></File>
<File RelativePath="..\panda\src\express\datagramIterator.I"></File>
<File RelativePath="..\panda\src\express\vector_uchar.h"></File>
<File RelativePath="..\panda\src\express\profileTimer.h"></File>
<File RelativePath="..\panda\src\express\datagramIterator.h"></File>
<File RelativePath="..\panda\src\express\threadSafePointerTo.cxx"></File>
<File RelativePath="..\panda\src\express\profileTimer.cxx"></File>
<File RelativePath="..\panda\src\express\datagramGenerator.cxx"></File>
<File RelativePath="..\panda\src\express\hashGeneratorBase.h"></File>
<File RelativePath="..\panda\src\express\patchfile.cxx"></File>

View File

@ -30,5 +30,4 @@
#include "pointerToArray.cxx"
#include "pointerToBase.cxx"
#include "pointerToVoid.cxx"
#include "profileTimer.cxx"
#include "pStatCollectorForwardBase.cxx"

View File

@ -1,67 +0,0 @@
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file profileTimer.I
*/
INLINE void ProfileTimer::
on() {
_on = TrueClock::get_global_ptr()->get_short_time();
}
INLINE double ProfileTimer::
getTime() {
double time = TrueClock::get_global_ptr()->get_short_time();
double et=_elapsedTime+=time-_on;
_on=time;
_elapsedTime=0.0;
return et;
}
INLINE void ProfileTimer::
mark(const char* tag) {
if (!_entries) {
std::cerr << "ProfileTimer::mark !_entries" << std::endl;
exit(1);
}
if (_entryCount < _maxEntries-1) {
TimerEntry& p=_entries[_entryCount];
p._tag=tag;
p._time=getTime();
++_entryCount;
} else {
_entries[_entryCount]._tag="*** Overflow ***";
}
}
INLINE void ProfileTimer::
off() {
double time = TrueClock::get_global_ptr()->get_short_time();
_elapsedTime+=time-_on;
}
INLINE void ProfileTimer::
off(const char* tag) {
double time = TrueClock::get_global_ptr()->get_short_time();
_elapsedTime+=time-_on;
mark(tag);
}
INLINE ProfileTimer::AutoTimer::
~AutoTimer() {
// If the AutoTimer is the first auto ctor, then it will be the last auto
// dtor, for that block. Therefore, now is the time to mark the time for
// the blockfunction:
_profile.mark(_tag);
--_profile._autoTimerCount;
}

View File

@ -1,179 +0,0 @@
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file profileTimer.cxx
*/
#include "profileTimer.h"
#include "pmap.h"
using std::ostream;
using std::string;
// See ProfileTimer.h for documentation.
EXPCL_PANDA_EXPRESS ProfileTimer Skyler_timer_global=ProfileTimer("startup");
ProfileTimer* ProfileTimer::_head;
ProfileTimer::
ProfileTimer(const char* name, int maxEntries) :
_entries(nullptr),
_autoTimerCount(0) {
// Keep a list of the ProfileTimers, so we can print them:
_next=_head;
_head=this;
if (name) {
init(name, maxEntries);
}
}
ProfileTimer::
ProfileTimer(const ProfileTimer& other) {
// Add to list:
_next=_head;
_head=this;
// init it:
_name=other._name;
_maxEntries=other._maxEntries;
if (_name) {
init(_name, _maxEntries);
}
// Copy other entries:
_on=other._on;
_elapsedTime=other._elapsedTime;
_autoTimerCount=other._autoTimerCount;
_entryCount=other._entryCount;
if (other._entries) {
memcpy(_entries, other._entries, _entryCount * sizeof(TimerEntry));
}
}
ProfileTimer::
~ProfileTimer() {
PANDA_FREE_ARRAY(_entries);
// Remove this from the list:
if (_head==this) {
_head=_next;
} else {
ProfileTimer* p=_head;
ProfileTimer* prior=p;
while (p) {
if (p==this) {
prior->_next=_next;
break;
}
prior=p;
p=p->_next;
}
}
}
void ProfileTimer::
init(const char* name, int maxEntries) {
_name=name;
_maxEntries=maxEntries;
_entries = (TimerEntry *)PANDA_MALLOC_ARRAY(_maxEntries * sizeof(TimerEntry));
_entryCount=0;
_elapsedTime=0.0;
_on=0.0;
}
double ProfileTimer::
getTotalTime() const {
double total=0;
int i;
for (i=0; i<_entryCount; ++i) {
TimerEntry& te=_entries[i];
total+=te._time;
}
return total;
}
void ProfileTimer::
consolidateAllTo(ostream &out) {
ProfileTimer* p=_head;
while (p) {
p->consolidateTo(out);
p=p->_next;
}
}
void ProfileTimer::
consolidateTo(ostream &out) const {
pmap<string, double> entries;
int i;
for (i=0; i<_entryCount; ++i) {
TimerEntry& te=_entries[i];
entries[te._tag]+=te._time;
}
out << "-------------------------------------------------------------------\n"
<< "Profile Timing of " << _name
<< "\n\n"; // ...should print data and time too.
double total=0;
{
pmap<string, double>::const_iterator i=entries.begin();
for (;i!=entries.end(); ++i) {
out << " " << std::setw(50) << i->first << ": "
<< std::setiosflags(std::ios::fixed) << std::setprecision(6) << std::setw(10) << i->second << "\n";
total+=i->second;
}
}
out << "\n [Total Time: "
<< std::setiosflags(std::ios::fixed) << std::setprecision(6) << total
<< " seconds]\n"
<< "-------------------------------------------------------------------\n";
out << std::endl;
}
void ProfileTimer::
printAllTo(ostream &out) {
ProfileTimer* p=_head;
while (p) {
p->printTo(out);
p=p->_next;
}
}
void ProfileTimer::
printTo(ostream &out) const {
out << "-------------------------------------------------------------------\n"
<< "Profile Timing of " << _name
<< "\n\n"; // ...should print data and time too.
double total=0;
int i;
for (i=0; i<_entryCount; ++i) {
TimerEntry& te=_entries[i];
out << " " << std::setw(50) << te._tag << ": "
<< std::setiosflags(std::ios::fixed) << std::setprecision(6) << std::setw(10) << te._time << "\n";
total+=te._time;
}
out << "\n [Total Time: "
<< std::setiosflags(std::ios::fixed) << std::setprecision(6) << total
<< " seconds]\n"
<< "-------------------------------------------------------------------\n";
out << std::endl;
}
ProfileTimer::AutoTimer::AutoTimer(ProfileTimer& profile, const char* tag) :
_profile(profile) {
_tag=tag;
if (_profile._autoTimerCount) {
// ...this is a nested call to another AutoTimer. Assign the time to the
// prior AutoTimer:
_profile.mark(_profile._entries[_profile._entryCount-1]._tag);
} else {
// ...this is not a nested call.
_profile.mark("other");
}
// Tell the profile that it's in an AutoTimer:
++_profile._autoTimerCount;
_profile.mark(_tag);
}

View File

@ -1,103 +0,0 @@
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file profileTimer.h
* @author skyler
*/
#ifndef PROFILETIMER_H
#define PROFILETIMER_H
#include "pandabase.h"
#include "trueClock.h"
/*
ProfileTimer
HowTo:
Create a ProfileTimer and hold onto it.
Call init() whenever you like (the timer doesn't
start yet).
Call on() to start the timer.
While the timer is on, call mark() at each point of interest,
in the code you are timing.
You can turn the timer off() and on() to skip things you
don't want to time.
When your timing is finished, call printTo() to see the
results (e.g. myTimer.printTo(cerr)).
Notes:
You should be able to time things down to the millisecond
well enough, but if you call on() and off() within micro-
seconds of each other, I don't think you'll get very good
results.
*/
class EXPCL_PANDA_EXPRESS ProfileTimer {
enum { MaxEntriesDefault=4096 };
PUBLISHED:
explicit ProfileTimer(const char* name=0, int maxEntries=MaxEntriesDefault);
ProfileTimer(const ProfileTimer& other);
~ProfileTimer();
void init(const char* name, int maxEntries=MaxEntriesDefault);
void on();
void mark(const char* tag);
void off();
void off(const char* tag);
// Don't call any of the following during timing: (Because they are slow,
// not because anything will break).
double getTotalTime() const;
static void consolidateAllTo(std::ostream &out=std::cout);
void consolidateTo(std::ostream &out=std::cout) const;
static void printAllTo(std::ostream &out=std::cout);
void printTo(std::ostream &out=std::cout) const;
public:
/*
e.g.
void Foo() {
ProfileTimer::AutoTimer(myProfiler, "Foo()");
...
}
*/
class EXPCL_PANDA_EXPRESS AutoTimer {
public:
AutoTimer(ProfileTimer& profile, const char* tag);
~AutoTimer();
protected:
ProfileTimer& _profile;
const char* _tag;
};
protected:
static ProfileTimer* _head;
ProfileTimer* _next;
class TimerEntry {
public:
const char* _tag; // not owned by this.
double _time;
};
double _on;
double _elapsedTime;
const char* _name; // not owned by this.
int _maxEntries;
int _entryCount;
TimerEntry* _entries;
int _autoTimerCount; // see class AutoTimer
double getTime();
friend class ProfileTimer::AutoTimer;
};
#include "profileTimer.I"
#endif //]

View File

@ -15,7 +15,6 @@
#include "temporaryFile.h"
#include "numeric_types.h"
#include "datagramIterator.h"
#include "profileTimer.h"
#include "config_putil.h"
#include "config_express.h"
#include "virtualFileSystem.h"