diff --git a/Gem/Code/Source/NetSoakTestSystemComponent.cpp b/Gem/Code/Source/NetSoakTestSystemComponent.cpp index a896dbd..16824cc 100644 --- a/Gem/Code/Source/NetSoakTestSystemComponent.cpp +++ b/Gem/Code/Source/NetSoakTestSystemComponent.cpp @@ -100,6 +100,7 @@ namespace NetSoakTest AZ_CVAR(uint16_t, soak_port, 33450, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "The port that this soak test will bind to for game traffic"); AZ_CVAR(ProtocolType, soak_protocol, ProtocolType::Udp, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "Soak test protocol"); AZ_CVAR(SoakMode, soak_mode, SoakMode::Loopback, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "Soak test mode"); + AZ_CVAR(SoakMode, soak_runtime, AZ::TimeMs(0), nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "How long to run the soak test for before dumping stats"); void NetSoakTestSystemComponent::Reflect(AZ::ReflectContext* context) { @@ -173,7 +174,14 @@ namespace NetSoakTest void NetSoakTestSystemComponent::OnTick(float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time) { - [[maybe_unused]] AZ::TimeMs elapsedMs = aznumeric_cast(aznumeric_cast(deltaTime / 1000.0f)); + AZ::TimeMs elapsedMs = aznumeric_cast(aznumeric_cast(deltaTime / 1000.0f)); + + total_elapsedMs += elapsedMs; + if (soak_runtime != AZ::TimeMs(0) && total_elapsedMs > soak_runtime) + { + DumpSoakStats(); + exit(0); + } NetSoakTestPackets::Small packet; @@ -196,7 +204,7 @@ namespace NetSoakTest unreliable.SetSmallDatum(2); connection.SendUnreliablePacket(unreliable); } - + }; m_networkInterface->GetConnectionSet().VisitConnections(visitor); diff --git a/Gem/Code/Source/NetSoakTestSystemComponent.h b/Gem/Code/Source/NetSoakTestSystemComponent.h index 3b59c4b..04b72b3 100644 --- a/Gem/Code/Source/NetSoakTestSystemComponent.h +++ b/Gem/Code/Source/NetSoakTestSystemComponent.h @@ -56,7 +56,7 @@ namespace NetSoakTest void Deactivate() override; //////////////////////////////////////////////////////////////////////// - + // AZ::TickBus::Handler overrides void OnTick(float deltaTime, AZ::ScriptTimePoint time) override; int GetTickOrder() override; @@ -74,5 +74,7 @@ namespace NetSoakTest private: AzNetworking::INetworkInterface* m_networkInterface = nullptr; AzNetworking::INetworkInterface* m_loopbackInterface = nullptr; + + AZ::TimeMs totalElapsedMs = AZ::TimeMs(0); }; }