Metrics for individual systems. Press N
This commit is contained in:
@@ -37,6 +37,8 @@
|
|||||||
#include "EComponentCreated.h"
|
#include "EComponentCreated.h"
|
||||||
#include "ResourceManager.h"
|
#include "ResourceManager.h"
|
||||||
|
|
||||||
|
#include "EKeyDown.h"
|
||||||
|
|
||||||
namespace dd
|
namespace dd
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -52,6 +54,10 @@ public:
|
|||||||
, m_LastEntityID(0) { }
|
, m_LastEntityID(0) { }
|
||||||
~World() { }
|
~World() { }
|
||||||
|
|
||||||
|
dd::EventRelay<World, dd::Events::KeyDown> m_EKeyDown;
|
||||||
|
bool OnKeyDown(const dd::Events::KeyDown &event);
|
||||||
|
|
||||||
|
|
||||||
/** Initialize the world.
|
/** Initialize the world.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+41
-8
@@ -87,14 +87,7 @@ void dd::World::Update(double dt)
|
|||||||
double t3 = stop - start;
|
double t3 = stop - start;
|
||||||
m_typeToTimeMap[type.c_str()].RSystemTime += t3;
|
m_typeToTimeMap[type.c_str()].RSystemTime += t3;
|
||||||
}
|
}
|
||||||
|
EventBroker->Process<World>();
|
||||||
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();
|
ProcessEntityRemovals();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,6 +186,8 @@ void dd::World::Initialize()
|
|||||||
system->RegisterResourceTypes(ResourceManager);
|
system->RegisterResourceTypes(ResourceManager);
|
||||||
system->Initialize();
|
system->Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EKeyDown, &World::OnKeyDown);
|
||||||
}
|
}
|
||||||
|
|
||||||
int dd::World::CommitEntity(EntityID entity)
|
int dd::World::CommitEntity(EntityID entity)
|
||||||
@@ -264,3 +259,41 @@ void dd::World::SetEntityParent(EntityID entity, EntityID newParent)
|
|||||||
m_EntityParents[entity] = newParent;
|
m_EntityParents[entity] = newParent;
|
||||||
m_EntityChildren[newParent].push_back(entity);
|
m_EntityChildren[newParent].push_back(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool dd::World::OnKeyDown(const dd::Events::KeyDown &event)
|
||||||
|
{
|
||||||
|
if (event.KeyCode == 78)
|
||||||
|
{
|
||||||
|
double eventTot = 0;
|
||||||
|
double updateTot = 0;
|
||||||
|
double rUpdateTot = 0;
|
||||||
|
double total = 0;
|
||||||
|
|
||||||
|
for (auto item : m_typeToTimeMap)
|
||||||
|
{
|
||||||
|
eventTot += item.second.EventTime;
|
||||||
|
updateTot += item.second.SystemTime;
|
||||||
|
rUpdateTot += item.second.RSystemTime;
|
||||||
|
}
|
||||||
|
total = eventTot + updateTot + rUpdateTot;
|
||||||
|
|
||||||
|
std::ofstream outFile;
|
||||||
|
outFile.open("../tools/system-metrics.txt");
|
||||||
|
outFile.clear();
|
||||||
|
outFile << "----------------------- Time measurements -----------------------\n";
|
||||||
|
for (auto item : m_typeToTimeMap)
|
||||||
|
{
|
||||||
|
outFile << "Type: " << item.first.c_str() << std::endl;
|
||||||
|
outFile << "Events: " << item.second.EventTime << " s. " << item.second.EventTime / eventTot * 100 << " % of total event time.\n";
|
||||||
|
outFile << "Update: " << item.second.SystemTime << " s. " << item.second.SystemTime / updateTot * 100 << " % of total update time.\n";
|
||||||
|
outFile << "Recursive Update: " << item.second.RSystemTime << " s. " << item.second.RSystemTime / rUpdateTot * 100 << " % of total recursive update time.\n";
|
||||||
|
double totalComplexity = (item.second.EventTime + item.second.SystemTime + item.second.RSystemTime) / total * 100;
|
||||||
|
outFile << "Total: " << totalComplexity << "% total system time." << std::endl << std::endl;
|
||||||
|
}
|
||||||
|
outFile << "-----------------------------------------------------------------";
|
||||||
|
outFile.close();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
//return false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
|||||||
es.Score = brick->Score;
|
es.Score = brick->Score;
|
||||||
EventBroker->Publish(es);
|
EventBroker->Publish(es);
|
||||||
|
|
||||||
std::cout << "Score: " << Score() << std::endl;
|
//std::cout << "Score: " << Score() << std::endl;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ bool dd::Systems::SoundSystem::OnPlaySound(const dd::Events::PlaySound &event)
|
|||||||
|
|
||||||
|
|
||||||
//Play
|
//Play
|
||||||
//alSourcePlay(source);
|
alSourcePlay(source);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user