From 2c3e90b126b8bcbb5f092a073bcb9d5822e2c146 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 24 Jul 2016 16:36:13 +0200 Subject: [PATCH] Added CBot performance counter --- src/common/profiler.h | 1 + src/graphics/engine/engine.cpp | 11 +++++++---- src/object/implementation/programmable_impl.cpp | 3 +++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/common/profiler.h b/src/common/profiler.h index 6eebc5f4..9e222079 100644 --- a/src/common/profiler.h +++ b/src/common/profiler.h @@ -36,6 +36,7 @@ enum PerformanceCounter PCNT_UPDATE_ENGINE, //! < frame update in CEngine PCNT_UPDATE_PARTICLE, //! < frame update in CParticle PCNT_UPDATE_GAME, //! < frame update in CRobotMain + PCNT_UPDATE_CBOT, //! < running CBot code (part of CRobotMain update) PCNT_RENDER_ALL, //! < the whole rendering process PCNT_RENDER_PARTICLE, //! < rendering the particles in 3D diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index be1b7468..36f08294 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -5032,7 +5032,7 @@ void CEngine::DrawStats() float height = m_text->GetAscent(FONT_COLOBOT, 13.0f); float width = 0.4f; - const int TOTAL_LINES = 20; + const int TOTAL_LINES = 21; Math::Point pos(0.05f * m_size.x/m_size.y, 0.05f + TOTAL_LINES * height); @@ -5083,9 +5083,11 @@ void CEngine::DrawStats() long long engineUpdate = CProfiler::GetPerformanceCounterTime(PCNT_UPDATE_ENGINE) - CProfiler::GetPerformanceCounterTime(PCNT_UPDATE_PARTICLE); + long long gameUpdate = CProfiler::GetPerformanceCounterTime(PCNT_UPDATE_GAME) - + CProfiler::GetPerformanceCounterTime(PCNT_UPDATE_CBOT); + long long otherUpdate = CProfiler::GetPerformanceCounterTime(PCNT_UPDATE_ALL) - - engineUpdate - - CProfiler::GetPerformanceCounterTime(PCNT_UPDATE_PARTICLE) - + CProfiler::GetPerformanceCounterTime(PCNT_UPDATE_ENGINE) - CProfiler::GetPerformanceCounterTime(PCNT_UPDATE_GAME); long long otherRender = CProfiler::GetPerformanceCounterTime(PCNT_RENDER_ALL) - @@ -5101,7 +5103,8 @@ void CEngine::DrawStats() drawStatsCounter("Frame update", PCNT_UPDATE_ALL); drawStatsValue (" Engine update", engineUpdate); drawStatsCounter(" Particle update", PCNT_UPDATE_PARTICLE); - drawStatsCounter(" Game update", PCNT_UPDATE_GAME); + drawStatsValue (" Game update", gameUpdate); + drawStatsCounter(" CBot programs", PCNT_UPDATE_CBOT); drawStatsValue( " Other update", otherUpdate); drawStatsLine( ""); drawStatsCounter("Frame render", PCNT_RENDER_ALL); diff --git a/src/object/implementation/programmable_impl.cpp b/src/object/implementation/programmable_impl.cpp index 0fb11bad..f02ba628 100644 --- a/src/object/implementation/programmable_impl.cpp +++ b/src/object/implementation/programmable_impl.cpp @@ -22,6 +22,7 @@ #include "CBot/CBot.h" #include "common/global.h" +#include "common/profiler.h" #include "level/robotmain.h" @@ -74,6 +75,7 @@ bool CProgrammableObjectImpl::EventProcess(const Event &event) if ( GetActivity() ) { + CProfiler::StartPerformanceCounter(PCNT_UPDATE_CBOT); if ( IsProgram() ) // current program? { if ( m_currentProgram->script->Continue() ) @@ -86,6 +88,7 @@ bool CProgrammableObjectImpl::EventProcess(const Event &event) { TraceRecordFrame(); } + CProfiler::StopPerformanceCounter(PCNT_UPDATE_CBOT); } }