[development] Revived the statistical profiler (#4378)
- Removed unused RunningStatisticsManager.cpp - Updated stats profiler proxy to use budgets - Fixed and re-enabled stats profiler tests - Enabled StatisticalProfilerProxySystemComponent in runtime Signed-off-by: AMZN-ScottR 24445312+AMZN-ScottR@users.noreply.github.com
This commit is contained in:
@@ -30,6 +30,8 @@
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
constexpr AZ::u32 ProfilerProxyGroup = AZ_CRC_CE("StatisticalProfilerProxyTests");
|
||||
|
||||
class StatisticalProfilerTest
|
||||
: public AllocatorsFixture
|
||||
{
|
||||
@@ -98,10 +100,10 @@ namespace UnitTest
|
||||
|
||||
AZ::Statistics::StatisticalProfiler<AZ::Crc32> profiler;
|
||||
|
||||
const AZ::Crc32 statIdPerformance = AZ_CRC("PerformanceResult", 0xc1f29a10);
|
||||
constexpr AZ::Crc32 statIdPerformance = AZ_CRC_CE("PerformanceResult");
|
||||
const AZStd::string statNamePerformance("PerformanceResult");
|
||||
|
||||
const AZ::Crc32 statIdBlock = AZ_CRC("Block", 0x831b9722);
|
||||
constexpr AZ::Crc32 statIdBlock = AZ_CRC_CE("Block");
|
||||
const AZStd::string statNameBlock("Block");
|
||||
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdPerformance, statNamePerformance, "us") != nullptr);
|
||||
@@ -175,10 +177,10 @@ namespace UnitTest
|
||||
|
||||
AZ::Statistics::StatisticalProfiler<AZ::Crc32, AZStd::shared_spin_mutex> profiler;
|
||||
|
||||
const AZ::Crc32 statIdPerformance = AZ_CRC("PerformanceResult", 0xc1f29a10);
|
||||
constexpr AZ::Crc32 statIdPerformance = AZ_CRC_CE("PerformanceResult");
|
||||
const AZStd::string statNamePerformance("PerformanceResult");
|
||||
|
||||
const AZ::Crc32 statIdBlock = AZ_CRC("Block", 0x831b9722);
|
||||
constexpr AZ::Crc32 statIdBlock = AZ_CRC_CE("Block");
|
||||
const AZStd::string statNameBlock("Block");
|
||||
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdPerformance, statNamePerformance, "us") != nullptr);
|
||||
@@ -317,26 +319,26 @@ namespace UnitTest
|
||||
AZ::Statistics::StatisticalProfilerProxy::TimedScope::ClearCachedProxy();
|
||||
AZ::Statistics::StatisticalProfilerProxy profilerProxy;
|
||||
AZ::Statistics::StatisticalProfilerProxy* proxy = AZ::Interface<AZ::Statistics::StatisticalProfilerProxy>::Get();
|
||||
AZ::Statistics::StatisticalProfilerProxy::StatisticalProfilerType& profiler = proxy->GetProfiler(AZ::Debug::ProfileCategory::Terrain);
|
||||
AZ::Statistics::StatisticalProfilerProxy::StatisticalProfilerType& profiler = proxy->GetProfiler(ProfilerProxyGroup);
|
||||
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdPerformance = "PerformanceResult";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdPerformance("PerformanceResult");
|
||||
const AZStd::string statNamePerformance("PerformanceResult");
|
||||
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdBlock = "Block";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdBlock("Block");
|
||||
const AZStd::string statNameBlock("Block");
|
||||
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdPerformance, statNamePerformance, "us") != nullptr);
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdBlock, statNameBlock, "us") != nullptr);
|
||||
|
||||
proxy->ActivateProfiler(AZ::Debug::ProfileCategory::Terrain, true);
|
||||
proxy->ActivateProfiler(ProfilerProxyGroup, true);
|
||||
|
||||
const int iter_count = 10;
|
||||
{
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(AZ::Debug::ProfileCategory::Terrain, statIdPerformance)
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(ProfilerProxyGroup, statIdPerformance)
|
||||
int counter = 0;
|
||||
for (int i = 0; i < iter_count; i++)
|
||||
{
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(AZ::Debug::ProfileCategory::Terrain, statIdBlock)
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(ProfilerProxyGroup, statIdBlock)
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
@@ -348,7 +350,7 @@ namespace UnitTest
|
||||
EXPECT_EQ(profiler.GetStatistic(statIdBlock)->GetNumSamples(), iter_count);
|
||||
|
||||
//Clean Up
|
||||
proxy->ActivateProfiler(AZ::Debug::ProfileCategory::Terrain, false);
|
||||
proxy->ActivateProfiler(ProfilerProxyGroup, false);
|
||||
|
||||
#undef CODE_PROFILER_PROXY_PUSH_TIME
|
||||
|
||||
@@ -362,12 +364,12 @@ namespace UnitTest
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType simple_thread1("simple_thread1");
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType simple_thread1_loop("simple_thread1_loop");
|
||||
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(AZ::Debug::ProfileCategory::Terrain, simple_thread1);
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(ProfilerProxyGroup, simple_thread1);
|
||||
|
||||
static int counter = 0;
|
||||
for (int i = 0; i < loop_cnt; i++)
|
||||
{
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(AZ::Debug::ProfileCategory::Terrain, simple_thread1_loop);
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(ProfilerProxyGroup, simple_thread1_loop);
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
@@ -377,12 +379,12 @@ namespace UnitTest
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType simple_thread2("simple_thread2");
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType simple_thread2_loop("simple_thread2_loop");
|
||||
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(AZ::Debug::ProfileCategory::Terrain, simple_thread2);
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(ProfilerProxyGroup, simple_thread2);
|
||||
|
||||
static int counter = 0;
|
||||
for (int i = 0; i < loop_cnt; i++)
|
||||
{
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(AZ::Debug::ProfileCategory::Terrain, simple_thread2_loop);
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(ProfilerProxyGroup, simple_thread2_loop);
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
@@ -392,12 +394,13 @@ namespace UnitTest
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType simple_thread3("simple_thread3");
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType simple_thread3_loop("simple_thread3_loop");
|
||||
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(AZ::Debug::ProfileCategory::Terrain, simple_thread3);
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(ProfilerProxyGroup, simple_thread3);
|
||||
|
||||
static int counter = 0;
|
||||
for (int i = 0; i < loop_cnt; i++)
|
||||
{
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(AZ::Debug::ProfileCategory::Terrain, simple_thread3_loop);
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(ProfilerProxyGroup, simple_thread3_loop);
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,21 +411,21 @@ namespace UnitTest
|
||||
AZ::Statistics::StatisticalProfilerProxy::TimedScope::ClearCachedProxy();
|
||||
AZ::Statistics::StatisticalProfilerProxy profilerProxy;
|
||||
AZ::Statistics::StatisticalProfilerProxy* proxy = AZ::Interface<AZ::Statistics::StatisticalProfilerProxy>::Get();
|
||||
AZ::Statistics::StatisticalProfilerProxy::StatisticalProfilerType& profiler = proxy->GetProfiler(AZ::Debug::ProfileCategory::Terrain);
|
||||
AZ::Statistics::StatisticalProfilerProxy::StatisticalProfilerType& profiler = proxy->GetProfiler(ProfilerProxyGroup);
|
||||
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread1 = "simple_thread1";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread1("simple_thread1");
|
||||
const AZStd::string statNameThread1("simple_thread1");
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread1Loop = "simple_thread1_loop";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread1Loop("simple_thread1_loop");
|
||||
const AZStd::string statNameThread1Loop("simple_thread1_loop");
|
||||
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread2 = "simple_thread2";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread2("simple_thread2");
|
||||
const AZStd::string statNameThread2("simple_thread2");
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread2Loop = "simple_thread2_loop";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread2Loop("simple_thread2_loop");
|
||||
const AZStd::string statNameThread2Loop("simple_thread2_loop");
|
||||
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread3 = "simple_thread3";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread3("simple_thread3");
|
||||
const AZStd::string statNameThread3("simple_thread3");
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread3Loop = "simple_thread3_loop";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread3Loop("simple_thread3_loop");
|
||||
const AZStd::string statNameThread3Loop("simple_thread3_loop");
|
||||
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdThread1, statNameThread1, "us"));
|
||||
@@ -432,7 +435,7 @@ namespace UnitTest
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdThread3, statNameThread3, "us"));
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdThread3Loop, statNameThread3Loop, "us"));
|
||||
|
||||
proxy->ActivateProfiler(AZ::Debug::ProfileCategory::Terrain, true);
|
||||
proxy->ActivateProfiler(ProfilerProxyGroup, true);
|
||||
|
||||
//Let's kickoff the threads to see how much contention affects the profiler's performance.
|
||||
const int iter_count = 10;
|
||||
@@ -459,7 +462,7 @@ namespace UnitTest
|
||||
EXPECT_EQ(profiler.GetStatistic(statIdThread3Loop)->GetNumSamples(), iter_count);
|
||||
|
||||
//Clean Up
|
||||
proxy->ActivateProfiler(AZ::Debug::ProfileCategory::Terrain, false);
|
||||
proxy->ActivateProfiler(ProfilerProxyGroup, false);
|
||||
}
|
||||
|
||||
/** Trace message handler to track messages during tests
|
||||
@@ -566,10 +569,10 @@ namespace UnitTest
|
||||
|
||||
AZ::Statistics::StatisticalProfiler<AZ::Crc32> profiler;
|
||||
|
||||
const AZ::Crc32 statIdPerformance = AZ_CRC("PerformanceResult", 0xc1f29a10);
|
||||
constexpr AZ::Crc32 statIdPerformance = AZ_CRC_CE("PerformanceResult");
|
||||
const AZStd::string statNamePerformance("PerformanceResult");
|
||||
|
||||
const AZ::Crc32 statIdBlock = AZ_CRC("Block", 0x831b9722);
|
||||
constexpr AZ::Crc32 statIdBlock = AZ_CRC_CE("Block");
|
||||
const AZStd::string statNameBlock("Block");
|
||||
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdPerformance, statNamePerformance, "us") != nullptr);
|
||||
@@ -647,10 +650,10 @@ namespace UnitTest
|
||||
|
||||
AZ::Statistics::StatisticalProfiler<AZ::Crc32, AZStd::shared_spin_mutex> profiler;
|
||||
|
||||
const AZ::Crc32 statIdPerformance = AZ_CRC("PerformanceResult", 0xc1f29a10);
|
||||
constexpr AZ::Crc32 statIdPerformance = AZ_CRC_CE("PerformanceResult");
|
||||
const AZStd::string statNamePerformance("PerformanceResult");
|
||||
|
||||
const AZ::Crc32 statIdBlock = AZ_CRC("Block", 0x831b9722);
|
||||
constexpr AZ::Crc32 statIdBlock = AZ_CRC_CE("Block");
|
||||
const AZStd::string statNameBlock("Block");
|
||||
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdPerformance, statNamePerformance, "us") != nullptr);
|
||||
@@ -745,26 +748,26 @@ namespace UnitTest
|
||||
AZ::Statistics::StatisticalProfilerProxy::TimedScope::ClearCachedProxy();
|
||||
AZ::Statistics::StatisticalProfilerProxy profilerProxy;
|
||||
AZ::Statistics::StatisticalProfilerProxy* proxy = AZ::Interface<AZ::Statistics::StatisticalProfilerProxy>::Get();
|
||||
AZ::Statistics::StatisticalProfilerProxy::StatisticalProfilerType& profiler = proxy->GetProfiler(AZ::Debug::ProfileCategory::Terrain);
|
||||
AZ::Statistics::StatisticalProfilerProxy::StatisticalProfilerType& profiler = proxy->GetProfiler(ProfilerProxyGroup);
|
||||
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdPerformance = "PerformanceResult";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdPerformance("PerformanceResult");
|
||||
const AZStd::string statNamePerformance("PerformanceResult");
|
||||
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdBlock = "Block";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdBlock("Block");
|
||||
const AZStd::string statNameBlock("Block");
|
||||
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdPerformance, statNamePerformance, "us") != nullptr);
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdBlock, statNameBlock, "us") != nullptr);
|
||||
|
||||
proxy->ActivateProfiler(AZ::Debug::ProfileCategory::Terrain, true);
|
||||
proxy->ActivateProfiler(ProfilerProxyGroup, true);
|
||||
|
||||
const int iter_count = 1000000;
|
||||
{
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(AZ::Debug::ProfileCategory::Terrain, statIdPerformance)
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(ProfilerProxyGroup, statIdPerformance)
|
||||
int counter = 0;
|
||||
for (int i = 0; i < iter_count; i++)
|
||||
{
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(AZ::Debug::ProfileCategory::Terrain, statIdBlock)
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(ProfilerProxyGroup, statIdBlock)
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
@@ -778,7 +781,7 @@ namespace UnitTest
|
||||
profiler.LogAndResetStats("StatisticalProfilerProxy");
|
||||
|
||||
//Clean Up
|
||||
proxy->ActivateProfiler(AZ::Debug::ProfileCategory::Terrain, false);
|
||||
proxy->ActivateProfiler(ProfilerProxyGroup, false);
|
||||
}
|
||||
|
||||
#undef CODE_PROFILER_PROXY_PUSH_TIME
|
||||
@@ -788,21 +791,21 @@ namespace UnitTest
|
||||
AZ::Statistics::StatisticalProfilerProxy::TimedScope::ClearCachedProxy();
|
||||
AZ::Statistics::StatisticalProfilerProxy profilerProxy;
|
||||
AZ::Statistics::StatisticalProfilerProxy* proxy = AZ::Interface<AZ::Statistics::StatisticalProfilerProxy>::Get();
|
||||
AZ::Statistics::StatisticalProfilerProxy::StatisticalProfilerType& profiler = proxy->GetProfiler(AZ::Debug::ProfileCategory::Terrain);
|
||||
AZ::Statistics::StatisticalProfilerProxy::StatisticalProfilerType& profiler = proxy->GetProfiler(ProfilerProxyGroup);
|
||||
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread1 = "simple_thread1";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread1("simple_thread1");
|
||||
const AZStd::string statNameThread1("simple_thread1");
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread1Loop = "simple_thread1_loop";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread1Loop("simple_thread1_loop");
|
||||
const AZStd::string statNameThread1Loop("simple_thread1_loop");
|
||||
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread2 = "simple_thread2";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread2("simple_thread2");
|
||||
const AZStd::string statNameThread2("simple_thread2");
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread2Loop = "simple_thread2_loop";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread2Loop("simple_thread2_loop");
|
||||
const AZStd::string statNameThread2Loop("simple_thread2_loop");
|
||||
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread3 = "simple_thread3";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread3("simple_thread3");
|
||||
const AZStd::string statNameThread3("simple_thread3");
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread3Loop = "simple_thread3_loop";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread3Loop("simple_thread3_loop");
|
||||
const AZStd::string statNameThread3Loop("simple_thread3_loop");
|
||||
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdThread1, statNameThread1, "us"));
|
||||
@@ -812,7 +815,7 @@ namespace UnitTest
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdThread3, statNameThread3, "us"));
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdThread3Loop, statNameThread3Loop, "us"));
|
||||
|
||||
proxy->ActivateProfiler(AZ::Debug::ProfileCategory::Terrain, true);
|
||||
proxy->ActivateProfiler(ProfilerProxyGroup, true);
|
||||
|
||||
//Let's kickoff the threads to see how much contention affects the profiler's performance.
|
||||
const int iter_count = 1000000;
|
||||
@@ -841,7 +844,7 @@ namespace UnitTest
|
||||
profiler.LogAndResetStats("3_Threads_StatisticalProfilerProxy");
|
||||
|
||||
//Clean Up
|
||||
proxy->ActivateProfiler(AZ::Debug::ProfileCategory::Terrain, false);
|
||||
proxy->ActivateProfiler(ProfilerProxyGroup, false);
|
||||
}
|
||||
|
||||
}//namespace UnitTest
|
||||
|
||||
Reference in New Issue
Block a user