stop pstats when stopped at prompt
This commit is contained in:
parent
7009801eb1
commit
543b7283b9
|
|
@ -49,6 +49,18 @@ class ShowBase:
|
|||
taskMgr.taskTimerVerbose = self.config.GetBool('task-timer-verbose', 0)
|
||||
taskMgr.pStatsTasks = self.config.GetBool('pstats-tasks', 0)
|
||||
|
||||
# Set up the TaskManager to reset the PStats clock back
|
||||
# whenever we resume from a pause. This callback function is
|
||||
# a little hacky, but we can't call it directly from within
|
||||
# the TaskManager because he doesn't know about PStats (and
|
||||
# has to run before libpanda is even loaded).
|
||||
|
||||
# Temporary try..except for old Pandas.
|
||||
try:
|
||||
taskMgr.resumeFunc = PStatClient.resumeAfterPause
|
||||
except:
|
||||
pass
|
||||
|
||||
fsmRedefine = self.config.GetBool('fsm-redefine', 0)
|
||||
State.FsmRedefine = fsmRedefine
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ class Task:
|
|||
self.avgDt = 0.0
|
||||
self.runningTotal = 0.0
|
||||
self.pstats = None
|
||||
self.resumeFunc = None
|
||||
|
||||
def getPriority(self):
|
||||
return self._priority
|
||||
|
|
@ -438,6 +439,10 @@ class TaskManager:
|
|||
# Paused at the prompt for a long time
|
||||
t = globalClock.getFrameTime()
|
||||
globalClock.setRealTime(t)
|
||||
|
||||
if self.resumeFunc != None:
|
||||
self.resumeFunc()
|
||||
|
||||
if self.stepping:
|
||||
self.step()
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -103,3 +103,16 @@ INLINE bool PStatClient::
|
|||
is_connected() {
|
||||
return get_global_pstats()->client_is_connected();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PStatClient::resume_after_pause
|
||||
// Access: Published
|
||||
// Description: Resumes the PStatClient after the simulation has been
|
||||
// paused for a while. This allows the stats to
|
||||
// continue exactly where it left off, instead of
|
||||
// leaving a big gap that would represent a chug.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void PStatClient::
|
||||
resume_after_pause() {
|
||||
get_global_pstats()->client_resume_after_pause();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,6 +209,10 @@ get_thread_name(int index) const {
|
|||
// global clock object, so the stats won't get mucked up
|
||||
// if you put the global clock in non-real-time mode or
|
||||
// something.
|
||||
//
|
||||
// On second thought, it works better to use the global
|
||||
// clock, so we don't lose a lot of time in the stats
|
||||
// while we're waiting at the prompt.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
const ClockObject &PStatClient::
|
||||
get_clock() const {
|
||||
|
|
@ -383,7 +387,19 @@ main_tick() {
|
|||
_interpreter_size_pcollector.set_level(MemoryUsage::get_interpreter_size());
|
||||
}
|
||||
|
||||
get_global_pstats()->get_main_thread().new_frame();
|
||||
get_global_pstats()->client_main_tick();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PStatClient::main_tick
|
||||
// Access: Public, Static
|
||||
// Description: A convenience function to call new_frame() on the
|
||||
// the given client's main thread.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PStatClient::
|
||||
client_main_tick() {
|
||||
_clock.tick();
|
||||
get_main_thread().new_frame();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -494,6 +510,24 @@ client_is_connected() const {
|
|||
return _is_connected;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PStatClient::client_resume_after_pause
|
||||
// Access: Published
|
||||
// Description: Resumes the PStatClient after the simulation has been
|
||||
// paused for a while. This allows the stats to
|
||||
// continue exactly where it left off, instead of
|
||||
// leaving a big gap that would represent a chug.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PStatClient::
|
||||
client_resume_after_pause() {
|
||||
// Simply reset the clock to the beginning of the last frame. This
|
||||
// may lose a frame, but on the other hand we won't skip a whole
|
||||
// slew of frames either.
|
||||
|
||||
double frame_time = _clock.get_frame_time();
|
||||
_clock.set_real_time(frame_time);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PStatClient::is_active
|
||||
// Access: Private
|
||||
|
|
@ -705,7 +739,7 @@ transmit_frame_data(int thread_index) {
|
|||
|
||||
// We don't want to send too many packets in a hurry and flood the
|
||||
// server. Check that enough time has elapsed for us to send a
|
||||
// new packet. If not, we'll drop this packet into the void and
|
||||
// new packet. If not, we'll drop this packet on the floor and
|
||||
// send a new one next time around.
|
||||
float now = _clock.get_real_time();
|
||||
if (now >= _threads[thread_index]._next_packet) {
|
||||
|
|
|
|||
|
|
@ -85,14 +85,19 @@ PUBLISHED:
|
|||
INLINE static void disconnect();
|
||||
INLINE static bool is_connected();
|
||||
|
||||
INLINE static void resume_after_pause();
|
||||
|
||||
public:
|
||||
static void main_tick();
|
||||
static PStatClient *get_global_pstats();
|
||||
|
||||
static void main_tick();
|
||||
void client_main_tick();
|
||||
bool client_connect(string hostname, int port);
|
||||
void client_disconnect();
|
||||
bool client_is_connected() const;
|
||||
|
||||
void client_resume_after_pause();
|
||||
|
||||
private:
|
||||
PStatCollector make_collector_with_relname(int parent_index, string relname);
|
||||
PStatCollector make_collector_with_name(int parent_index, const string &name);
|
||||
|
|
@ -203,6 +208,7 @@ PUBLISHED:
|
|||
INLINE static bool connect(const string & = string(), int = -1) { return false; }
|
||||
INLINE static void disconnect() { }
|
||||
INLINE static bool is_connected() { return false; }
|
||||
INLINE static void resume_after_pause() { }
|
||||
|
||||
public:
|
||||
static void main_tick() { }
|
||||
|
|
|
|||
Loading…
Reference in New Issue