don't ask for the time unless stats are running

This commit is contained in:
David Rose 2001-07-16 21:41:52 +00:00
parent 27bfe1b0c7
commit 34c695359e
3 changed files with 65 additions and 6 deletions

View File

@ -549,7 +549,31 @@ is_active(int collector_index, int thread_index) const {
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: PStatClient::start_collector // Function: PStatClient::start
// Access: Private
// Description: Marks the indicated collector index as started.
// Normally you would not use this interface directly;
// instead, call PStatCollector::start().
////////////////////////////////////////////////////////////////////
void PStatClient::
start(int collector_index, int thread_index) {
nassertv(collector_index >= 0 && collector_index < (int)_collectors.size());
nassertv(thread_index >= 0 && thread_index < (int)_threads.size());
if (_collectors[collector_index]._def->_is_active &&
_threads[thread_index]._is_active) {
if (_collectors[collector_index]._per_thread[thread_index]._nested_count == 0) {
// This collector wasn't already started in this thread; record
// a new data point.
_threads[thread_index]._frame_data.add_start(collector_index,
_clock.get_real_time());
}
_collectors[collector_index]._per_thread[thread_index]._nested_count++;
}
}
////////////////////////////////////////////////////////////////////
// Function: PStatClient::start
// Access: Private // Access: Private
// Description: Marks the indicated collector index as started. // Description: Marks the indicated collector index as started.
// Normally you would not use this interface directly; // Normally you would not use this interface directly;
@ -572,7 +596,40 @@ start(int collector_index, int thread_index, float as_of) {
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: PStatClient::start_collector // Function: PStatClient::stop
// Access: Private
// Description: Marks the indicated collector index as stopped.
// Normally you would not use this interface directly;
// instead, call PStatCollector::stop().
////////////////////////////////////////////////////////////////////
void PStatClient::
stop(int collector_index, int thread_index) {
nassertv(collector_index >= 0 && collector_index < (int)_collectors.size());
nassertv(thread_index >= 0 && thread_index < (int)_threads.size());
if (_collectors[collector_index]._def->_is_active &&
_threads[thread_index]._is_active) {
if (_collectors[collector_index]._per_thread[thread_index]._nested_count == 0) {
pstats_cat.warning()
<< "Collector " << get_collector_fullname(collector_index)
<< " was already stopped in thread " << get_thread_name(thread_index)
<< "!\n";
return;
}
_collectors[collector_index]._per_thread[thread_index]._nested_count--;
if (_collectors[collector_index]._per_thread[thread_index]._nested_count == 0) {
// This collector has now been completely stopped; record a new
// data point.
_threads[thread_index]._frame_data.add_stop(collector_index,
_clock.get_real_time());
}
}
}
////////////////////////////////////////////////////////////////////
// Function: PStatClient::stop
// Access: Private // Access: Private
// Description: Marks the indicated collector index as stopped. // Description: Marks the indicated collector index as stopped.
// Normally you would not use this interface directly; // Normally you would not use this interface directly;

View File

@ -105,7 +105,9 @@ private:
bool is_active(int collector_index, int thread_index) const; bool is_active(int collector_index, int thread_index) const;
void start(int collector_index, int thread_index);
void start(int collector_index, int thread_index, float as_of); void start(int collector_index, int thread_index, float as_of);
void stop(int collector_index, int thread_index);
void stop(int collector_index, int thread_index, float as_of); void stop(int collector_index, int thread_index, float as_of);
void clear_level(int collector_index, int thread_index); void clear_level(int collector_index, int thread_index);

View File

@ -145,7 +145,7 @@ is_active() {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE void PStatCollector:: INLINE void PStatCollector::
start() { start() {
_client->start(_index, 0, _client->_clock.get_real_time()); _client->start(_index, 0);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -156,7 +156,7 @@ start() {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE void PStatCollector:: INLINE void PStatCollector::
stop() { stop() {
_client->stop(_index, 0, _client->_clock.get_real_time()); _client->stop(_index, 0);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -241,7 +241,7 @@ is_active(const PStatThread &thread) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE void PStatCollector:: INLINE void PStatCollector::
start(const PStatThread &thread) { start(const PStatThread &thread) {
_client->start(_index, thread._index, _client->_clock.get_real_time()); _client->start(_index, thread._index);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -265,7 +265,7 @@ start(const PStatThread &thread, float as_of) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE void PStatCollector:: INLINE void PStatCollector::
stop(const PStatThread &thread) { stop(const PStatThread &thread) {
_client->stop(_index, thread._index, _client->_clock.get_real_time()); _client->stop(_index, thread._index);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////