From 086bdbce70ae84e6fe74b6b9545926dab9aafbe5 Mon Sep 17 00:00:00 2001 From: Stiffly Date: Wed, 23 Sep 2015 17:19:57 +0200 Subject: [PATCH] Accumulated measures of Events, Update, Recursive Updates. --- include/Core/World.h | 9 +++++++++ src/game/Core/World.cpp | 23 +++++++++++++++++++---- src/game/Sound/SoundSystem.cpp | 2 +- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/include/Core/World.h b/include/Core/World.h index 5c66d52..3b5d216 100644 --- a/include/Core/World.h +++ b/include/Core/World.h @@ -248,6 +248,15 @@ protected: EntityID GenerateEntityID(); void RecycleEntityID(EntityID id); + +private: + //Benchmarking + struct TimeMeasure { + double EventTime; + double SystemTime; + double RSystemTime; + }; + std::map m_typeToTimeMap; }; template diff --git a/src/game/Core/World.cpp b/src/game/Core/World.cpp index 677a5dc..2439cab 100644 --- a/src/game/Core/World.cpp +++ b/src/game/Core/World.cpp @@ -59,27 +59,42 @@ void dd::World::Update(double dt) const std::string &type = pair.first; auto system = pair.second; - LOG_INFO("System: %s", type.c_str()); + std::map::iterator it = m_typeToTimeMap.find(type.c_str()); + if (it == m_typeToTimeMap.end()) { + //Does not contain item + TimeMeasure t; + t.EventTime = 0; + t.SystemTime = 0; + t.RSystemTime = 0; + m_typeToTimeMap[type.c_str()] = t; + } double start = glfwGetTime(); EventBroker->Process(type); double stop = glfwGetTime(); double t1 = stop - start; - LOG_INFO("Events: %f", t1); + m_typeToTimeMap[type.c_str()].EventTime += t1; start = glfwGetTime(); system->Update(dt); stop = glfwGetTime(); double t2 = stop - start; - LOG_INFO("Systems: %f", t2); + m_typeToTimeMap[type.c_str()].SystemTime += t2; start = glfwGetTime(); RecursiveUpdate(system, dt, 0); stop = glfwGetTime(); double t3 = stop - start; - LOG_INFO("Recursive Systems: %f", t3); + m_typeToTimeMap[type.c_str()].RSystemTime += t3; } + for (auto item : m_typeToTimeMap) + { + LOG_INFO("Type %s", item.first.c_str()); + LOG_INFO("Events: %f", item.second.EventTime); + LOG_INFO("Systems: %f", item.second.SystemTime); + LOG_INFO("Recursive Systems: %f", item.second.RSystemTime); + } ProcessEntityRemovals(); } diff --git a/src/game/Sound/SoundSystem.cpp b/src/game/Sound/SoundSystem.cpp index aaca752..724f4cd 100644 --- a/src/game/Sound/SoundSystem.cpp +++ b/src/game/Sound/SoundSystem.cpp @@ -100,7 +100,7 @@ bool dd::Systems::SoundSystem::OnPlaySound(const dd::Events::PlaySound &event) //Play - alSourcePlay(source); + //alSourcePlay(source); return true; }