Don't store data when the profiler is disabled.
This commit is contained in:
parent
d800a8c0bc
commit
d8fe700f64
@ -160,8 +160,9 @@ int Profiler::getThreadID()
|
|||||||
/// Push a new marker that starts now
|
/// Push a new marker that starts now
|
||||||
void Profiler::pushCPUMarker(const char* name, const video::SColor& colour)
|
void Profiler::pushCPUMarker(const char* name, const video::SColor& colour)
|
||||||
{
|
{
|
||||||
// Don't do anything when frozen
|
// Don't do anything when disabled or frozen
|
||||||
if (m_freeze_state == FROZEN || m_freeze_state == WAITING_FOR_UNFREEZE)
|
if (!UserConfigParams::m_profiler_enabled ||
|
||||||
|
m_freeze_state == FROZEN || m_freeze_state == WAITING_FOR_UNFREEZE )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
double start = getTimeMilliseconds() - m_time_last_sync;
|
double start = getTimeMilliseconds() - m_time_last_sync;
|
||||||
@ -191,14 +192,24 @@ void Profiler::pushCPUMarker(const char* name, const video::SColor& colour)
|
|||||||
/// Stop the last pushed marker
|
/// Stop the last pushed marker
|
||||||
void Profiler::popCPUMarker()
|
void Profiler::popCPUMarker()
|
||||||
{
|
{
|
||||||
// Don't do anything when frozen
|
// Don't do anything when disabled or frozen
|
||||||
if(m_freeze_state == FROZEN || m_freeze_state == WAITING_FOR_UNFREEZE)
|
if( !UserConfigParams::m_profiler_enabled ||
|
||||||
|
m_freeze_state == FROZEN || m_freeze_state == WAITING_FOR_UNFREEZE )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_lock.lock();
|
m_lock.lock();
|
||||||
int thread_id = getThreadID();
|
int thread_id = getThreadID();
|
||||||
ThreadData &td = m_all_threads_data[thread_id];
|
ThreadData &td = m_all_threads_data[thread_id];
|
||||||
|
|
||||||
|
// When the profiler gets enabled (which happens in the middle of the
|
||||||
|
// main loop), there can be some pops without matching pushes (for one
|
||||||
|
// frame) - ignore those events.
|
||||||
|
if (td.m_event_stack.size() == 0)
|
||||||
|
{
|
||||||
|
m_lock.unlock();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
assert(td.m_event_stack.size() > 0);
|
assert(td.m_event_stack.size() > 0);
|
||||||
|
|
||||||
const std::string &name = td.m_event_stack.back();
|
const std::string &name = td.m_event_stack.back();
|
||||||
@ -218,7 +229,7 @@ void Profiler::popCPUMarker()
|
|||||||
void Profiler::synchronizeFrame()
|
void Profiler::synchronizeFrame()
|
||||||
{
|
{
|
||||||
// Don't do anything when frozen
|
// Don't do anything when frozen
|
||||||
if(m_freeze_state == FROZEN)
|
if(!UserConfigParams::m_profiler_enabled || m_freeze_state == FROZEN)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Avoid using several times getTimeMilliseconds(),
|
// Avoid using several times getTimeMilliseconds(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user