Added profiling events for ProtocolManager.

This commit is contained in:
hiker 2017-08-11 09:48:34 +10:00
parent aa757637ec
commit 4c0ffdb055

View File

@ -23,6 +23,7 @@
#include "network/stk_host.hpp" #include "network/stk_host.hpp"
#include "network/stk_peer.hpp" #include "network/stk_peer.hpp"
#include "utils/log.hpp" #include "utils/log.hpp"
#include "utils/profiler.hpp"
#include "utils/time.hpp" #include "utils/time.hpp"
#include "utils/vs.hpp" #include "utils/vs.hpp"
@ -52,7 +53,9 @@ void* ProtocolManager::mainLoop(void* data)
while(manager && !manager->m_exit.getAtomic()) while(manager && !manager->m_exit.getAtomic())
{ {
manager->asynchronousUpdate(); manager->asynchronousUpdate();
PROFILER_PUSH_CPU_MARKER("sleep", 0, 255, 255);
StkTime::sleep(2); StkTime::sleep(2);
PROFILER_POP_CPU_MARKER();
} }
return NULL; return NULL;
} // protocolManagerAsynchronousUpdate } // protocolManagerAsynchronousUpdate
@ -457,6 +460,7 @@ void ProtocolManager::update(float dt)
*/ */
void ProtocolManager::asynchronousUpdate() void ProtocolManager::asynchronousUpdate()
{ {
PROFILER_PUSH_CPU_MARKER("Message delivery", 255, 0, 0);
// Update from ProtocolManager thread only: // Update from ProtocolManager thread only:
assert(pthread_equal(pthread_self(), m_asynchronous_update_thread)); assert(pthread_equal(pthread_self(), m_asynchronous_update_thread));
@ -487,6 +491,9 @@ void ProtocolManager::asynchronousUpdate()
} // while i != m_events_to_process.end() } // while i != m_events_to_process.end()
m_async_events_to_process.unlock(); m_async_events_to_process.unlock();
PROFILER_POP_CPU_MARKER();
PROFILER_PUSH_CPU_MARKER("Message delivery", 255, 0, 0);
// Second: update all running protocols // Second: update all running protocols
// ==================================== // ====================================
// Now update all protocols. // Now update all protocols.
@ -501,6 +508,9 @@ void ProtocolManager::asynchronousUpdate()
opt.unlock(); opt.unlock();
} }
PROFILER_POP_CPU_MARKER();
PROFILER_PUSH_CPU_MARKER("Process events", 0, 255, 0);
// Process queued events (start, pause, ...) for protocols asynchronously // Process queued events (start, pause, ...) for protocols asynchronously
// ====================================================================== // ======================================================================
m_requests.lock(); m_requests.lock();
@ -530,6 +540,7 @@ void ProtocolManager::asynchronousUpdate()
m_requests.lock(); m_requests.lock();
} // while m_requests.size()>0 } // while m_requests.size()>0
m_requests.unlock(); m_requests.unlock();
PROFILER_POP_CPU_MARKER();
} // asynchronousUpdate } // asynchronousUpdate
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------