Profiler: Runtime region name support (#2924)
* Profiler: add support for runtime region names * Profiler: fix group name collisions * Profiler: use set of GroupRegionNames * Profiler: add comments + named constant Signed-off-by: Jacob Hilliard <jhlliar@amazon.com>
This commit is contained in:
@@ -74,6 +74,20 @@ namespace AZ
|
||||
{
|
||||
}
|
||||
|
||||
AZStd::size_t CachedTimeRegion::GroupRegionName::Hash::operator()(const CachedTimeRegion::GroupRegionName& name) const
|
||||
{
|
||||
AZStd::size_t seed = 0;
|
||||
AZStd::hash_combine(seed, name.m_groupName);
|
||||
AZStd::hash_combine(seed, name.m_regionName);
|
||||
return seed;
|
||||
}
|
||||
|
||||
bool CachedTimeRegion::GroupRegionName::operator==(const GroupRegionName& other) const
|
||||
{
|
||||
return (m_groupName == other.m_groupName) && (m_regionName == other.m_regionName);
|
||||
}
|
||||
|
||||
|
||||
// --- CpuProfilerImpl ---
|
||||
|
||||
void CpuProfilerImpl::Init()
|
||||
@@ -218,6 +232,19 @@ namespace AZ
|
||||
return m_enabled;
|
||||
}
|
||||
|
||||
const CachedTimeRegion::GroupRegionName& CpuProfilerImpl::InsertDynamicName(const char* groupName, const AZStd::string& regionName)
|
||||
{
|
||||
AZStd::scoped_lock lock(m_dynamicNameMutex);
|
||||
AZ_Warning("CpuProfiler", m_regionNameStringPool.size() < MaxRegionStringPoolSize,
|
||||
"Stored dynamic region names are accumulating. Consider removing a AZ_ATOM_PROFILE_DYNAMIC invocation.");
|
||||
auto [regionNameItr, wasRegionInserted] = m_regionNameStringPool.insert(regionName);
|
||||
|
||||
CachedTimeRegion::GroupRegionName newGroupRegionName(groupName, regionNameItr->c_str());
|
||||
auto [groupRegionNameItr, wasGroupRegionInserted] = m_dynamicGroupRegionNamePool.insert(newGroupRegionName);
|
||||
|
||||
return *groupRegionNameItr;
|
||||
}
|
||||
|
||||
void CpuProfilerImpl::OnSystemTick()
|
||||
{
|
||||
if (!m_enabled)
|
||||
|
||||
Reference in New Issue
Block a user