World::MemoryUsage returns approximate value of component pool memory usage
This commit is contained in:
@@ -65,6 +65,8 @@ public:
|
|||||||
iterator end() const;
|
iterator end() const;
|
||||||
size_t size() const;
|
size_t size() const;
|
||||||
|
|
||||||
|
std::size_t MemoryUsage() const;
|
||||||
|
|
||||||
//Dumps information about what the pool memory looks like right now
|
//Dumps information about what the pool memory looks like right now
|
||||||
//into an output stream (e.g. file/std::cout, anything that has an operator<<)
|
//into an output stream (e.g. file/std::cout, anything that has an operator<<)
|
||||||
//Interpret the data in the memory as InterpretType.
|
//Interpret the data in the memory as InterpretType.
|
||||||
|
|||||||
@@ -194,6 +194,11 @@ public:
|
|||||||
return m_ExtraMemory.size();
|
return m_ExtraMemory.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::size_t MemoryUsage() const
|
||||||
|
{
|
||||||
|
return size() * m_Stride;
|
||||||
|
}
|
||||||
|
|
||||||
//Dumps information about what the pool memory looks like right now
|
//Dumps information about what the pool memory looks like right now
|
||||||
//into an output stream (e.g. file/std::cout, anything that has an operator<<)
|
//into an output stream (e.g. file/std::cout, anything that has an operator<<)
|
||||||
//Interpret the data in the memory as InterpretType.
|
//Interpret the data in the memory as InterpretType.
|
||||||
|
|||||||
@@ -50,6 +50,9 @@ public:
|
|||||||
// Get the textual name of an entity
|
// Get the textual name of an entity
|
||||||
std::string GetName(EntityID entity) const;
|
std::string GetName(EntityID entity) const;
|
||||||
|
|
||||||
|
// Get an approximate number for component pool memory usage
|
||||||
|
std::size_t MemoryUsage() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EventBroker* m_EventBroker = nullptr;
|
EventBroker* m_EventBroker = nullptr;
|
||||||
EntityID m_CurrentEntityID = 0;
|
EntityID m_CurrentEntityID = 0;
|
||||||
|
|||||||
@@ -112,6 +112,11 @@ size_t ComponentPool::size() const
|
|||||||
return m_Pool.size();
|
return m_Pool.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::size_t ComponentPool::MemoryUsage() const
|
||||||
|
{
|
||||||
|
return m_Pool.MemoryUsage();
|
||||||
|
}
|
||||||
|
|
||||||
template <typename InterpretType /*= char*/>
|
template <typename InterpretType /*= char*/>
|
||||||
void ComponentPool::Dump() const
|
void ComponentPool::Dump() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -151,6 +151,17 @@ std::string World::GetName(EntityID entity) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::size_t World::MemoryUsage() const
|
||||||
|
{
|
||||||
|
std::size_t mem = 0;
|
||||||
|
|
||||||
|
for (auto& kv : m_ComponentPools) {
|
||||||
|
mem += kv.second->MemoryUsage();
|
||||||
|
}
|
||||||
|
|
||||||
|
return mem;
|
||||||
|
}
|
||||||
|
|
||||||
EntityID World::generateEntityID()
|
EntityID World::generateEntityID()
|
||||||
{
|
{
|
||||||
// TODO: Make EntityID generation smarter
|
// TODO: Make EntityID generation smarter
|
||||||
|
|||||||
Reference in New Issue
Block a user