From 551c3536206186bd32399ad7bd744c15c0db405c Mon Sep 17 00:00:00 2001 From: kvassall-unity Date: Thu, 18 Mar 2021 16:55:47 -0500 Subject: [PATCH 1/7] test: Building out a test to get some surface coverage of the mlapi profiler functionality --- .../Tests/Runtime/ProfilerTests.cs | 165 ++++++++++++++++++ .../Tests/Runtime/ProfilerTests.cs.meta | 11 ++ 2 files changed, 176 insertions(+) create mode 100644 com.unity.multiplayer.mlapi/Tests/Runtime/ProfilerTests.cs create mode 100644 com.unity.multiplayer.mlapi/Tests/Runtime/ProfilerTests.cs.meta diff --git a/com.unity.multiplayer.mlapi/Tests/Runtime/ProfilerTests.cs b/com.unity.multiplayer.mlapi/Tests/Runtime/ProfilerTests.cs new file mode 100644 index 0000000000..3348d64e43 --- /dev/null +++ b/com.unity.multiplayer.mlapi/Tests/Runtime/ProfilerTests.cs @@ -0,0 +1,165 @@ +using System; +using System.Collections.Generic; +using MLAPI.Logging; +using MLAPI.Profiling; +using NUnit.Framework; + +namespace MLAPI.RuntimeTests +{ + public class TestTransport : ITransportProfilerData + { + internal static class ProfilerConstants + { + public const string TransportTestData = nameof(TransportTestData); + } + + private static readonly ProfilingDataStore TransportProfilerData = new ProfilingDataStore(); + + public void BeginNewTick() + { + TransportProfilerData.Clear(); + } + + public IReadOnlyDictionary GetTransportProfilerData() + { + return TransportProfilerData.GetReadonly(); + } + + public void Send(string testMessage) + { + PerformanceDataManager.Increment(ProfilerConstants.TransportTestData); + } + } + + public class TestProfiler + { + public delegate void PerformanceDataEventHandler(PerformanceTickData profilerData); + + public static event PerformanceDataEventHandler OnPerformanceDataEvent; + + internal static class ProfilerConstants + { + public const string NetworkTestData = nameof(NetworkTestData); + } + + private TestTransport m_Transport; + private int m_Counter; + + public void Initialize() + { + m_Transport = new TestTransport(); + m_Counter = 0; + } + + public void ProfilerBeginTick() + { + PerformanceDataManager.BeginNewTick(); + m_Transport.BeginNewTick(); + m_Counter++; + } + + public void NotifyProfilerListeners() + { + m_Counter--; + m_Counter = Math.Max(0, m_Counter); + + var data = PerformanceDataManager.GetData(); + var eventHandler = OnPerformanceDataEvent; + if (eventHandler != null) + { + if (data != null) + { + var transportProfilerData = m_Transport.GetTransportProfilerData(); + + PerformanceDataManager.AddTransportData(transportProfilerData); + + eventHandler.Invoke(data); + } + else + { + NetworkLog.LogWarning( + "No data available. Did you forget to call PerformanceDataManager.BeginNewTick() first?"); + } + } + } + + public void Send(string testMessage) + { + if (m_Counter != 1) + { + throw new NoTickDataException(m_Counter); + } + PerformanceDataManager.Increment(ProfilerConstants.NetworkTestData); + m_Transport.Send(testMessage); + } + } + + public class NoTickDataException : Exception + { + public NoTickDataException(int counter) + : base(counter.ToString()) + { + } + } + + public class ProfilerTests + { + [SetUp] + public void Setup() + { + TestProfiler.OnPerformanceDataEvent += TestProfilerOnPerformanceDataEventNormal; + } + + [Test] + public void TestNormalRegisterAndNotifyFlow() + { + var testProfiler = new TestProfiler(); + testProfiler.Initialize(); + + testProfiler.ProfilerBeginTick(); + testProfiler.Send("NormalFlow"); + testProfiler.NotifyProfilerListeners(); + } + + [Test] + public void TestDroppedRegisterAndNotifyFlow() + { + var testProfiler = new TestProfiler(); + testProfiler.Initialize(); + + testProfiler.ProfilerBeginTick(); + testProfiler.Send("DroppedFlow"); + testProfiler.NotifyProfilerListeners(); + + // Capturing data after notifying listeners is bad + Assert.Catch(() => + { + testProfiler.Send("DroppedFlow"); + }); + Assert.Catch(() => + { + testProfiler.Send("DroppedFlow"); + }); + testProfiler.ProfilerBeginTick(); + } + + + [Test] + public void TestProperMatchRegisterAndNotifyFlow() + { + var testProfiler = new TestProfiler(); + testProfiler.Initialize(); + + testProfiler.NotifyProfilerListeners(); + testProfiler.ProfilerBeginTick(); + testProfiler.Send("Normal"); + testProfiler.NotifyProfilerListeners(); + } + + private static void TestProfilerOnPerformanceDataEventNormal(PerformanceTickData profilerData) + { + Assert.IsTrue(profilerData.HasData(TestProfiler.ProfilerConstants.NetworkTestData)); + Assert.IsTrue(profilerData.HasData(TestTransport.ProfilerConstants.TransportTestData)); + } + } +} diff --git a/com.unity.multiplayer.mlapi/Tests/Runtime/ProfilerTests.cs.meta b/com.unity.multiplayer.mlapi/Tests/Runtime/ProfilerTests.cs.meta new file mode 100644 index 0000000000..a3e75c0aa1 --- /dev/null +++ b/com.unity.multiplayer.mlapi/Tests/Runtime/ProfilerTests.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 830b42ee5eea844d19be6416eed6d071 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From d549d4c6955472433af7dc9a8013f22a3a6ea163 Mon Sep 17 00:00:00 2001 From: kvassall-unity Date: Fri, 19 Mar 2021 16:31:28 -0500 Subject: [PATCH 2/7] Updating to have a more testable interface and have reusable code that MLAPI could use directly --- .../Profiling/PerformanceDataManager.cs | 4 +- .../Tests/Editor/ProfilerTests.cs | 269 ++++++++++++++++++ .../{Runtime => Editor}/ProfilerTests.cs.meta | 2 +- .../Tests/Runtime/ProfilerTests.cs | 165 ----------- 4 files changed, 273 insertions(+), 167 deletions(-) create mode 100644 com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs rename com.unity.multiplayer.mlapi/Tests/{Runtime => Editor}/ProfilerTests.cs.meta (83%) delete mode 100644 com.unity.multiplayer.mlapi/Tests/Runtime/ProfilerTests.cs diff --git a/com.unity.multiplayer.mlapi/Runtime/Profiling/PerformanceDataManager.cs b/com.unity.multiplayer.mlapi/Runtime/Profiling/PerformanceDataManager.cs index 2c9442e895..c94c19c962 100644 --- a/com.unity.multiplayer.mlapi/Runtime/Profiling/PerformanceDataManager.cs +++ b/com.unity.multiplayer.mlapi/Runtime/Profiling/PerformanceDataManager.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using UnityEngine; namespace MLAPI.Profiling { @@ -11,8 +12,9 @@ internal static class PerformanceDataManager internal static void BeginNewTick() { s_TickId = Math.Max(s_TickId, 0); + s_TickId++; s_ProfilerData.Reset(); - s_ProfilerData.TickId = s_TickId++; + s_ProfilerData.TickId = s_TickId; } internal static void Increment(string fieldName, int count = 1) diff --git a/com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs b/com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs new file mode 100644 index 0000000000..647eee90da --- /dev/null +++ b/com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs @@ -0,0 +1,269 @@ +using System; +using System.Collections.Generic; +using MLAPI.Logging; +using MLAPI.Profiling; +using NUnit.Framework; +using UnityEditor; +using UnityEngine; + +namespace MLAPI.RuntimeTests +{ + public class TestTransport : ITransportProfilerData + { + internal static class ProfilerConstants + { + public const string TransportTestData = nameof(TransportTestData); + } + + private static readonly ProfilingDataStore TransportProfilerData = new ProfilingDataStore(); + + public void BeginNewTick() + { + TransportProfilerData.Clear(); + } + + public IReadOnlyDictionary GetTransportProfilerData() + { + return TransportProfilerData.GetReadonly(); + } + + public void Send(string testMessage) + { + PerformanceDataManager.Increment(ProfilerConstants.TransportTestData); + } + } + + public static class ProfilerNotifier + { + public delegate void PerformanceDataEventHandler(PerformanceTickData profilerData); + + public static event PerformanceDataEventHandler OnPerformanceDataEvent; + + public delegate void NoTickDataHandler(); + + public static event NoTickDataHandler OnNoTickDataEvent; + + private static IHasProfilableTransport s_HasProfilableTransport; + private static bool s_FailsafeCheck; + + public static void Initialize(IHasProfilableTransport hasProfilableNetwork) + { + s_HasProfilableTransport = hasProfilableNetwork + ?? throw new ArgumentNullException( + $"{nameof(hasProfilableNetwork)} was not set"); + s_FailsafeCheck = false; + } + + public static void ProfilerBeginTick() + { + PerformanceDataManager.BeginNewTick(); + var transport = s_HasProfilableTransport.GetTransport(); + transport?.BeginNewTick(); + s_FailsafeCheck = true; + } + + public static void NotifyProfilerListeners() + { + if (!s_FailsafeCheck) + return; + + s_FailsafeCheck = false; + + var data = PerformanceDataManager.GetData(); + var eventHandler = OnPerformanceDataEvent; + if (eventHandler != null) + { + if (data != null) + { + var transport = s_HasProfilableTransport.GetTransport(); + if (transport != null) + { + var transportProfilerData = transport.GetTransportProfilerData(); + + PerformanceDataManager.AddTransportData(transportProfilerData); + } + + eventHandler.Invoke(data); + } + else + { + NetworkLog.LogWarning( + "No data available. Did you forget to call PerformanceDataManager.BeginNewTick() first?"); + } + } + } + + public static void Increment(string fieldName, int count = 1) + { + if (!s_FailsafeCheck) + { + OnNoTickDataEvent?.Invoke(); + } + + PerformanceDataManager.Increment(fieldName); + } + } + + public interface IHasProfilableTransport + { + public ITransportProfilerData GetTransport(); + } + + public class TestHasProfilable : IHasProfilableTransport + { + internal static class ProfilerConstants + { + public const string NetworkTestData = nameof(NetworkTestData); + } + + private TestTransport m_Transport; + + public ITransportProfilerData GetTransport() + { + return m_Transport; + } + + public void Initialize(bool useNullTransport) + { + m_Transport = useNullTransport ? null : new TestTransport(); + ProfilerNotifier.Initialize(this); + } + + public static void ProfilerBeginTick() + { + ProfilerNotifier.ProfilerBeginTick(); + } + + public static void NotifyProfilerListeners() + { + ProfilerNotifier.NotifyProfilerListeners(); + } + + public void Send() + { + ProfilerNotifier.Increment(ProfilerConstants.NetworkTestData); + m_Transport?.Send("testMessage"); + } + } + + public class NoTickDataException : Exception + { + } + + public class ProfilerTests + { + private static void BreakDownTestProfiler(bool useNullTransport) + { + if (useNullTransport) + { + ProfilerNotifier.OnPerformanceDataEvent -= TestProfilerOnPerformanceDataEventNoTransport; + } + else + { + ProfilerNotifier.OnPerformanceDataEvent -= TestProfilerOnPerformanceDataEventNormal; + } + + ProfilerNotifier.OnNoTickDataEvent -= TestProfilerNotifierOnOnNoTickDataEvent; + } + + private static TestHasProfilable SetupTestProfiler(bool useNullTransport) + { + ProfilerNotifier.OnNoTickDataEvent += TestProfilerNotifierOnOnNoTickDataEvent; + if (useNullTransport) + { + ProfilerNotifier.OnPerformanceDataEvent += TestProfilerOnPerformanceDataEventNoTransport; + } + else + { + ProfilerNotifier.OnPerformanceDataEvent += TestProfilerOnPerformanceDataEventNormal; + } + + EditorApplication.UnlockReloadAssemblies(); + var testProfiler = new TestHasProfilable(); + testProfiler.Initialize(useNullTransport); + return testProfiler; + } + + [Test] + public void TestNormalRegisterAndNotifyFlowNull() + { + const bool useNullTransport = true; + TestHasProfilable testProfiler = SetupTestProfiler(useNullTransport); + + TestHasProfilable.ProfilerBeginTick(); + testProfiler.Send(); + TestHasProfilable.NotifyProfilerListeners(); + + BreakDownTestProfiler(useNullTransport); + } + + [Test] + public void TestNormalRegisterAndNotifyFlow() + { + const bool useNullTransport = false; + TestHasProfilable testProfiler = SetupTestProfiler(useNullTransport); + + TestHasProfilable.ProfilerBeginTick(); + testProfiler.Send(); + TestHasProfilable.NotifyProfilerListeners(); + + BreakDownTestProfiler(useNullTransport); + } + + [Test] + public void TestDroppedRegisterAndNotifyFlow() + { + const bool useNullTransport = false; + TestHasProfilable testProfiler = SetupTestProfiler(useNullTransport); + + TestHasProfilable.ProfilerBeginTick(); + testProfiler.Send(); + TestHasProfilable.NotifyProfilerListeners(); + + // Capturing data after notifying listeners is bad + Assert.Catch(() => + { + testProfiler.Send(); + }); + Assert.Catch(() => + { + testProfiler.Send(); + }); + TestHasProfilable.ProfilerBeginTick(); + + BreakDownTestProfiler(useNullTransport); + } + + + [Test] + public void TestProperMatchRegisterAndNotifyFlow() + { + const bool useNullTransport = false; + TestHasProfilable testProfiler = SetupTestProfiler(useNullTransport); + + TestHasProfilable.NotifyProfilerListeners(); + TestHasProfilable.ProfilerBeginTick(); + testProfiler.Send(); + TestHasProfilable.NotifyProfilerListeners(); + + BreakDownTestProfiler(useNullTransport); + } + + private static void TestProfilerOnPerformanceDataEventNormal(PerformanceTickData profilerData) + { + Assert.IsTrue(profilerData.HasData(TestHasProfilable.ProfilerConstants.NetworkTestData)); + Assert.IsTrue(profilerData.HasData(TestTransport.ProfilerConstants.TransportTestData)); + } + + private static void TestProfilerOnPerformanceDataEventNoTransport(PerformanceTickData profilerData) + { + Assert.IsTrue(profilerData.HasData(TestHasProfilable.ProfilerConstants.NetworkTestData)); + Assert.IsFalse(profilerData.HasData(TestTransport.ProfilerConstants.TransportTestData)); + } + + private static void TestProfilerNotifierOnOnNoTickDataEvent() + { + throw new NoTickDataException(); + } + } +} diff --git a/com.unity.multiplayer.mlapi/Tests/Runtime/ProfilerTests.cs.meta b/com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs.meta similarity index 83% rename from com.unity.multiplayer.mlapi/Tests/Runtime/ProfilerTests.cs.meta rename to com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs.meta index a3e75c0aa1..ff71e12578 100644 --- a/com.unity.multiplayer.mlapi/Tests/Runtime/ProfilerTests.cs.meta +++ b/com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 830b42ee5eea844d19be6416eed6d071 +guid: 69750fc1f921f490fabad933b42ff9c5 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/com.unity.multiplayer.mlapi/Tests/Runtime/ProfilerTests.cs b/com.unity.multiplayer.mlapi/Tests/Runtime/ProfilerTests.cs deleted file mode 100644 index 3348d64e43..0000000000 --- a/com.unity.multiplayer.mlapi/Tests/Runtime/ProfilerTests.cs +++ /dev/null @@ -1,165 +0,0 @@ -using System; -using System.Collections.Generic; -using MLAPI.Logging; -using MLAPI.Profiling; -using NUnit.Framework; - -namespace MLAPI.RuntimeTests -{ - public class TestTransport : ITransportProfilerData - { - internal static class ProfilerConstants - { - public const string TransportTestData = nameof(TransportTestData); - } - - private static readonly ProfilingDataStore TransportProfilerData = new ProfilingDataStore(); - - public void BeginNewTick() - { - TransportProfilerData.Clear(); - } - - public IReadOnlyDictionary GetTransportProfilerData() - { - return TransportProfilerData.GetReadonly(); - } - - public void Send(string testMessage) - { - PerformanceDataManager.Increment(ProfilerConstants.TransportTestData); - } - } - - public class TestProfiler - { - public delegate void PerformanceDataEventHandler(PerformanceTickData profilerData); - - public static event PerformanceDataEventHandler OnPerformanceDataEvent; - - internal static class ProfilerConstants - { - public const string NetworkTestData = nameof(NetworkTestData); - } - - private TestTransport m_Transport; - private int m_Counter; - - public void Initialize() - { - m_Transport = new TestTransport(); - m_Counter = 0; - } - - public void ProfilerBeginTick() - { - PerformanceDataManager.BeginNewTick(); - m_Transport.BeginNewTick(); - m_Counter++; - } - - public void NotifyProfilerListeners() - { - m_Counter--; - m_Counter = Math.Max(0, m_Counter); - - var data = PerformanceDataManager.GetData(); - var eventHandler = OnPerformanceDataEvent; - if (eventHandler != null) - { - if (data != null) - { - var transportProfilerData = m_Transport.GetTransportProfilerData(); - - PerformanceDataManager.AddTransportData(transportProfilerData); - - eventHandler.Invoke(data); - } - else - { - NetworkLog.LogWarning( - "No data available. Did you forget to call PerformanceDataManager.BeginNewTick() first?"); - } - } - } - - public void Send(string testMessage) - { - if (m_Counter != 1) - { - throw new NoTickDataException(m_Counter); - } - PerformanceDataManager.Increment(ProfilerConstants.NetworkTestData); - m_Transport.Send(testMessage); - } - } - - public class NoTickDataException : Exception - { - public NoTickDataException(int counter) - : base(counter.ToString()) - { - } - } - - public class ProfilerTests - { - [SetUp] - public void Setup() - { - TestProfiler.OnPerformanceDataEvent += TestProfilerOnPerformanceDataEventNormal; - } - - [Test] - public void TestNormalRegisterAndNotifyFlow() - { - var testProfiler = new TestProfiler(); - testProfiler.Initialize(); - - testProfiler.ProfilerBeginTick(); - testProfiler.Send("NormalFlow"); - testProfiler.NotifyProfilerListeners(); - } - - [Test] - public void TestDroppedRegisterAndNotifyFlow() - { - var testProfiler = new TestProfiler(); - testProfiler.Initialize(); - - testProfiler.ProfilerBeginTick(); - testProfiler.Send("DroppedFlow"); - testProfiler.NotifyProfilerListeners(); - - // Capturing data after notifying listeners is bad - Assert.Catch(() => - { - testProfiler.Send("DroppedFlow"); - }); - Assert.Catch(() => - { - testProfiler.Send("DroppedFlow"); - }); - testProfiler.ProfilerBeginTick(); - } - - - [Test] - public void TestProperMatchRegisterAndNotifyFlow() - { - var testProfiler = new TestProfiler(); - testProfiler.Initialize(); - - testProfiler.NotifyProfilerListeners(); - testProfiler.ProfilerBeginTick(); - testProfiler.Send("Normal"); - testProfiler.NotifyProfilerListeners(); - } - - private static void TestProfilerOnPerformanceDataEventNormal(PerformanceTickData profilerData) - { - Assert.IsTrue(profilerData.HasData(TestProfiler.ProfilerConstants.NetworkTestData)); - Assert.IsTrue(profilerData.HasData(TestTransport.ProfilerConstants.TransportTestData)); - } - } -} From fdeb073c96928c313aa25a22f5c4f79e55664d98 Mon Sep 17 00:00:00 2001 From: kvassall-unity Date: Mon, 22 Mar 2021 11:07:28 -0500 Subject: [PATCH 3/7] Hooking the Network manager up to the ProfilerNotifier --- .../Runtime/Core/NetworkManager.cs | 37 +++------ .../Profiling/IHasProfilableTransport.cs | 7 ++ .../Profiling/IHasProfilableTransport.cs.meta | 3 + .../Runtime/Profiling/ProfilerCountersInfo.cs | 8 +- .../Runtime/Profiling/ProfilerNotifier.cs | 76 ++++++++++++++++++ .../Profiling/ProfilerNotifier.cs.meta | 3 + .../Tests/Editor/ProfilerTests.cs | 77 ------------------- 7 files changed, 105 insertions(+), 106 deletions(-) create mode 100644 com.unity.multiplayer.mlapi/Runtime/Profiling/IHasProfilableTransport.cs create mode 100644 com.unity.multiplayer.mlapi/Runtime/Profiling/IHasProfilableTransport.cs.meta create mode 100644 com.unity.multiplayer.mlapi/Runtime/Profiling/ProfilerNotifier.cs create mode 100644 com.unity.multiplayer.mlapi/Runtime/Profiling/ProfilerNotifier.cs.meta diff --git a/com.unity.multiplayer.mlapi/Runtime/Core/NetworkManager.cs b/com.unity.multiplayer.mlapi/Runtime/Core/NetworkManager.cs index 7b0ddf8239..4050b0bf57 100644 --- a/com.unity.multiplayer.mlapi/Runtime/Core/NetworkManager.cs +++ b/com.unity.multiplayer.mlapi/Runtime/Core/NetworkManager.cs @@ -29,7 +29,7 @@ namespace MLAPI /// The main component of the library /// [AddComponentMenu("MLAPI/NetworkManager", -100)] - public class NetworkManager : MonoBehaviour, INetworkUpdateSystem + public class NetworkManager : MonoBehaviour, INetworkUpdateSystem, IHasProfilableTransport { [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] @@ -56,10 +56,6 @@ public class NetworkManager : MonoBehaviour, INetworkUpdateSystem internal RpcQueueContainer RpcQueueContainer { get; private set; } internal NetworkTickSystem NetworkTickSystem { get; private set; } - public delegate void PerformanceDataEventHandler(PerformanceTickData profilerData); - - public static event PerformanceDataEventHandler OnPerformanceDataEvent; - /// /// A synchronized time, represents the time in seconds since the server application started. Is replicated across all clients /// @@ -386,6 +382,8 @@ private void Init(bool server) NetworkConfig.NetworkTransport.ResetChannelCache(); NetworkConfig.NetworkTransport.Init(); + + ProfilerNotifier.Initialize(this); } /// @@ -1483,34 +1481,17 @@ internal void HandleApproval(ulong clientId, bool createPlayerObject, ulong? pla private void ProfilerBeginTick() { - PerformanceDataManager.BeginNewTick(); - if (NetworkConfig.NetworkTransport is ITransportProfilerData profileTransport) - { - profileTransport.BeginNewTick(); - } + ProfilerNotifier.ProfilerBeginTick(); } private void NotifyProfilerListeners() { - var data = PerformanceDataManager.GetData(); - var eventHandler = OnPerformanceDataEvent; - if (eventHandler != null) - { - if (data != null) - { - if (NetworkConfig.NetworkTransport is ITransportProfilerData profileTransport) - { - var transportProfilerData = profileTransport.GetTransportProfilerData(); - PerformanceDataManager.AddTransportData(transportProfilerData); - } + ProfilerNotifier.NotifyProfilerListeners(); + } - eventHandler.Invoke(data); - } - else - { - NetworkLog.LogWarning($"No data available. Did you forget to call {nameof(PerformanceDataManager)}.{nameof(PerformanceDataManager.BeginNewTick)}() first?"); - } - } + public ITransportProfilerData GetTransport() + { + return NetworkConfig.NetworkTransport as ITransportProfilerData; } } } diff --git a/com.unity.multiplayer.mlapi/Runtime/Profiling/IHasProfilableTransport.cs b/com.unity.multiplayer.mlapi/Runtime/Profiling/IHasProfilableTransport.cs new file mode 100644 index 0000000000..03ae4e81ee --- /dev/null +++ b/com.unity.multiplayer.mlapi/Runtime/Profiling/IHasProfilableTransport.cs @@ -0,0 +1,7 @@ +namespace MLAPI.Profiling +{ + public interface IHasProfilableTransport + { + ITransportProfilerData GetTransport(); + } +} diff --git a/com.unity.multiplayer.mlapi/Runtime/Profiling/IHasProfilableTransport.cs.meta b/com.unity.multiplayer.mlapi/Runtime/Profiling/IHasProfilableTransport.cs.meta new file mode 100644 index 0000000000..dbcd7976d2 --- /dev/null +++ b/com.unity.multiplayer.mlapi/Runtime/Profiling/IHasProfilableTransport.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 02cc48a5664f497ca5c792b68cb15ba0 +timeCreated: 1616427501 \ No newline at end of file diff --git a/com.unity.multiplayer.mlapi/Runtime/Profiling/ProfilerCountersInfo.cs b/com.unity.multiplayer.mlapi/Runtime/Profiling/ProfilerCountersInfo.cs index 8a9fd576bf..e4977db766 100644 --- a/com.unity.multiplayer.mlapi/Runtime/Profiling/ProfilerCountersInfo.cs +++ b/com.unity.multiplayer.mlapi/Runtime/Profiling/ProfilerCountersInfo.cs @@ -83,7 +83,13 @@ internal static class ProfilerCountersInfo private static void RegisterMLAPIPerformanceEvent() { InitializeCounters(); - NetworkManager.OnPerformanceDataEvent += OnPerformanceTickData; + ProfilerNotifier.OnPerformanceDataEvent += OnPerformanceTickData; + ProfilerNotifier.OnNoTickDataEvent += OnNoTickData; + } + + private static void OnNoTickData() + { + Debug.LogWarning("There was a profiler event that was not captured in a tick"); } private static void InitializeCounters() diff --git a/com.unity.multiplayer.mlapi/Runtime/Profiling/ProfilerNotifier.cs b/com.unity.multiplayer.mlapi/Runtime/Profiling/ProfilerNotifier.cs new file mode 100644 index 0000000000..ac448830bb --- /dev/null +++ b/com.unity.multiplayer.mlapi/Runtime/Profiling/ProfilerNotifier.cs @@ -0,0 +1,76 @@ +using System; +using MLAPI.Logging; + +namespace MLAPI.Profiling +{ + public static class ProfilerNotifier + { + public delegate void PerformanceDataEventHandler(PerformanceTickData profilerData); + + public static event PerformanceDataEventHandler OnPerformanceDataEvent; + + public delegate void NoTickDataHandler(); + + public static event NoTickDataHandler OnNoTickDataEvent; + + private static IHasProfilableTransport s_HasProfilableTransport; + private static bool s_FailsafeCheck; + + public static void Initialize(IHasProfilableTransport hasProfilableNetwork) + { + s_HasProfilableTransport = hasProfilableNetwork + ?? throw new ArgumentNullException( + $"{nameof(hasProfilableNetwork)} was not set"); + s_FailsafeCheck = false; + } + + public static void ProfilerBeginTick() + { + PerformanceDataManager.BeginNewTick(); + var transport = s_HasProfilableTransport.GetTransport(); + transport?.BeginNewTick(); + s_FailsafeCheck = true; + } + + public static void NotifyProfilerListeners() + { + if (!s_FailsafeCheck) + return; + + s_FailsafeCheck = false; + + var data = PerformanceDataManager.GetData(); + var eventHandler = OnPerformanceDataEvent; + if (eventHandler != null) + { + if (data != null) + { + var transport = s_HasProfilableTransport.GetTransport(); + if (transport != null) + { + var transportProfilerData = transport.GetTransportProfilerData(); + + PerformanceDataManager.AddTransportData(transportProfilerData); + } + + eventHandler.Invoke(data); + } + else + { + NetworkLog.LogWarning( + "No data available. Did you forget to call PerformanceDataManager.BeginNewTick() first?"); + } + } + } + + public static void Increment(string fieldName, int count = 1) + { + if (!s_FailsafeCheck) + { + OnNoTickDataEvent?.Invoke(); + } + + PerformanceDataManager.Increment(fieldName); + } + } +} diff --git a/com.unity.multiplayer.mlapi/Runtime/Profiling/ProfilerNotifier.cs.meta b/com.unity.multiplayer.mlapi/Runtime/Profiling/ProfilerNotifier.cs.meta new file mode 100644 index 0000000000..015d08aa4b --- /dev/null +++ b/com.unity.multiplayer.mlapi/Runtime/Profiling/ProfilerNotifier.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 12af6f0ff6554caaab917445ae94d809 +timeCreated: 1616427513 \ No newline at end of file diff --git a/com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs b/com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs index 647eee90da..14a6feb219 100644 --- a/com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs +++ b/com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using MLAPI.Logging; using MLAPI.Profiling; using NUnit.Framework; using UnityEditor; @@ -33,82 +32,6 @@ public void Send(string testMessage) } } - public static class ProfilerNotifier - { - public delegate void PerformanceDataEventHandler(PerformanceTickData profilerData); - - public static event PerformanceDataEventHandler OnPerformanceDataEvent; - - public delegate void NoTickDataHandler(); - - public static event NoTickDataHandler OnNoTickDataEvent; - - private static IHasProfilableTransport s_HasProfilableTransport; - private static bool s_FailsafeCheck; - - public static void Initialize(IHasProfilableTransport hasProfilableNetwork) - { - s_HasProfilableTransport = hasProfilableNetwork - ?? throw new ArgumentNullException( - $"{nameof(hasProfilableNetwork)} was not set"); - s_FailsafeCheck = false; - } - - public static void ProfilerBeginTick() - { - PerformanceDataManager.BeginNewTick(); - var transport = s_HasProfilableTransport.GetTransport(); - transport?.BeginNewTick(); - s_FailsafeCheck = true; - } - - public static void NotifyProfilerListeners() - { - if (!s_FailsafeCheck) - return; - - s_FailsafeCheck = false; - - var data = PerformanceDataManager.GetData(); - var eventHandler = OnPerformanceDataEvent; - if (eventHandler != null) - { - if (data != null) - { - var transport = s_HasProfilableTransport.GetTransport(); - if (transport != null) - { - var transportProfilerData = transport.GetTransportProfilerData(); - - PerformanceDataManager.AddTransportData(transportProfilerData); - } - - eventHandler.Invoke(data); - } - else - { - NetworkLog.LogWarning( - "No data available. Did you forget to call PerformanceDataManager.BeginNewTick() first?"); - } - } - } - - public static void Increment(string fieldName, int count = 1) - { - if (!s_FailsafeCheck) - { - OnNoTickDataEvent?.Invoke(); - } - - PerformanceDataManager.Increment(fieldName); - } - } - - public interface IHasProfilableTransport - { - public ITransportProfilerData GetTransport(); - } - public class TestHasProfilable : IHasProfilableTransport { internal static class ProfilerConstants From 749a9459788abd3dad457c9923b067d639fb763f Mon Sep 17 00:00:00 2001 From: kvassall-unity Date: Mon, 22 Mar 2021 14:29:28 -0500 Subject: [PATCH 4/7] Updating to make tests more explicit on the type of things we should be testing --- .../Runtime/Core/NetworkManager.cs | 4 +- .../Profiling/IHasProfilableTransport.cs | 2 +- .../Runtime/Profiling/ProfilerNotifier.cs | 4 +- .../Tests/Editor/ProfilerTests.cs | 134 ++++++++++-------- 4 files changed, 79 insertions(+), 65 deletions(-) diff --git a/com.unity.multiplayer.mlapi/Runtime/Core/NetworkManager.cs b/com.unity.multiplayer.mlapi/Runtime/Core/NetworkManager.cs index 4050b0bf57..8e4a0e3fb1 100644 --- a/com.unity.multiplayer.mlapi/Runtime/Core/NetworkManager.cs +++ b/com.unity.multiplayer.mlapi/Runtime/Core/NetworkManager.cs @@ -1489,9 +1489,9 @@ private void NotifyProfilerListeners() ProfilerNotifier.NotifyProfilerListeners(); } - public ITransportProfilerData GetTransport() + public ITransportProfilerData Transport { - return NetworkConfig.NetworkTransport as ITransportProfilerData; + get { return NetworkConfig.NetworkTransport as ITransportProfilerData; } } } } diff --git a/com.unity.multiplayer.mlapi/Runtime/Profiling/IHasProfilableTransport.cs b/com.unity.multiplayer.mlapi/Runtime/Profiling/IHasProfilableTransport.cs index 03ae4e81ee..861a5e619b 100644 --- a/com.unity.multiplayer.mlapi/Runtime/Profiling/IHasProfilableTransport.cs +++ b/com.unity.multiplayer.mlapi/Runtime/Profiling/IHasProfilableTransport.cs @@ -2,6 +2,6 @@ namespace MLAPI.Profiling { public interface IHasProfilableTransport { - ITransportProfilerData GetTransport(); + ITransportProfilerData Transport { get; } } } diff --git a/com.unity.multiplayer.mlapi/Runtime/Profiling/ProfilerNotifier.cs b/com.unity.multiplayer.mlapi/Runtime/Profiling/ProfilerNotifier.cs index ac448830bb..2962f3c558 100644 --- a/com.unity.multiplayer.mlapi/Runtime/Profiling/ProfilerNotifier.cs +++ b/com.unity.multiplayer.mlapi/Runtime/Profiling/ProfilerNotifier.cs @@ -27,7 +27,7 @@ public static void Initialize(IHasProfilableTransport hasProfilableNetwork) public static void ProfilerBeginTick() { PerformanceDataManager.BeginNewTick(); - var transport = s_HasProfilableTransport.GetTransport(); + var transport = s_HasProfilableTransport.Transport; transport?.BeginNewTick(); s_FailsafeCheck = true; } @@ -45,7 +45,7 @@ public static void NotifyProfilerListeners() { if (data != null) { - var transport = s_HasProfilableTransport.GetTransport(); + var transport = s_HasProfilableTransport.Transport; if (transport != null) { var transportProfilerData = transport.GetTransportProfilerData(); diff --git a/com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs b/com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs index 14a6feb219..acc8bab262 100644 --- a/com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs +++ b/com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs @@ -3,7 +3,6 @@ using MLAPI.Profiling; using NUnit.Framework; using UnityEditor; -using UnityEngine; namespace MLAPI.RuntimeTests { @@ -32,7 +31,7 @@ public void Send(string testMessage) } } - public class TestHasProfilable : IHasProfilableTransport + public class TestProfiler : IHasProfilableTransport { internal static class ProfilerConstants { @@ -40,15 +39,15 @@ internal static class ProfilerConstants } private TestTransport m_Transport; + private bool m_HasSentAnyData; - public ITransportProfilerData GetTransport() - { - return m_Transport; - } + public ITransportProfilerData Transport => m_Transport; + public bool HasSentAnyData => m_HasSentAnyData; public void Initialize(bool useNullTransport) { m_Transport = useNullTransport ? null : new TestTransport(); + m_HasSentAnyData = false; ProfilerNotifier.Initialize(this); } @@ -66,6 +65,7 @@ public void Send() { ProfilerNotifier.Increment(ProfilerConstants.NetworkTestData); m_Transport?.Send("testMessage"); + m_HasSentAnyData = true; } } @@ -75,73 +75,104 @@ public class NoTickDataException : Exception public class ProfilerTests { - private static void BreakDownTestProfiler(bool useNullTransport) + private static TestProfiler SetupTestProfiler(bool useNullTransport) + { + var testProfiler = new TestProfiler(); + testProfiler.Initialize(useNullTransport); + return testProfiler; + } + + private static void RegisterStaticAsserts(bool useNullTransport) { + ProfilerNotifier.OnNoTickDataEvent += RaiseExceptionNoTickDataEvent; if (useNullTransport) { - ProfilerNotifier.OnPerformanceDataEvent -= TestProfilerOnPerformanceDataEventNoTransport; + ProfilerNotifier.OnPerformanceDataEvent += AssertNetworkDataExists; } else { - ProfilerNotifier.OnPerformanceDataEvent -= TestProfilerOnPerformanceDataEventNormal; + ProfilerNotifier.OnPerformanceDataEvent += AssertNetworkAndTransportDataExists; } + } - ProfilerNotifier.OnNoTickDataEvent -= TestProfilerNotifierOnOnNoTickDataEvent; + private static void AssertNetworkAndTransportDataExists(PerformanceTickData profilerData) + { + Assert.IsTrue(profilerData.HasData(TestProfiler.ProfilerConstants.NetworkTestData)); + Assert.IsTrue(profilerData.HasData(TestTransport.ProfilerConstants.TransportTestData)); } - private static TestHasProfilable SetupTestProfiler(bool useNullTransport) + private static void AssertNetworkDataExists(PerformanceTickData profilerData) { - ProfilerNotifier.OnNoTickDataEvent += TestProfilerNotifierOnOnNoTickDataEvent; - if (useNullTransport) - { - ProfilerNotifier.OnPerformanceDataEvent += TestProfilerOnPerformanceDataEventNoTransport; - } - else - { - ProfilerNotifier.OnPerformanceDataEvent += TestProfilerOnPerformanceDataEventNormal; - } + Assert.IsTrue(profilerData.HasData(TestProfiler.ProfilerConstants.NetworkTestData)); + Assert.IsFalse(profilerData.HasData(TestTransport.ProfilerConstants.TransportTestData)); + } - EditorApplication.UnlockReloadAssemblies(); - var testProfiler = new TestHasProfilable(); - testProfiler.Initialize(useNullTransport); - return testProfiler; + private static void RaiseExceptionNoTickDataEvent() + { + throw new NoTickDataException(); + } + + [TearDown] + public void TearDown() + { + ProfilerNotifier.OnPerformanceDataEvent -= AssertNetworkAndTransportDataExists; + ProfilerNotifier.OnPerformanceDataEvent -= AssertNetworkDataExists; + ProfilerNotifier.OnNoTickDataEvent -= RaiseExceptionNoTickDataEvent; + } + + [Test] + public void TestSentNoData() + { + const bool useNullTransport = true; + TestProfiler testProfiler = SetupTestProfiler(useNullTransport); + + TestProfiler.ProfilerBeginTick(); + TestProfiler.NotifyProfilerListeners(); + + Assert.False(testProfiler.HasSentAnyData); } [Test] public void TestNormalRegisterAndNotifyFlowNull() { const bool useNullTransport = true; - TestHasProfilable testProfiler = SetupTestProfiler(useNullTransport); + TestProfiler testProfiler = SetupTestProfiler(useNullTransport); + + RegisterStaticAsserts(useNullTransport); - TestHasProfilable.ProfilerBeginTick(); + TestProfiler.ProfilerBeginTick(); testProfiler.Send(); - TestHasProfilable.NotifyProfilerListeners(); + TestProfiler.NotifyProfilerListeners(); - BreakDownTestProfiler(useNullTransport); + Assert.IsTrue(testProfiler.HasSentAnyData); } [Test] public void TestNormalRegisterAndNotifyFlow() { const bool useNullTransport = false; - TestHasProfilable testProfiler = SetupTestProfiler(useNullTransport); + TestProfiler testProfiler = SetupTestProfiler(useNullTransport); + + RegisterStaticAsserts(useNullTransport); - TestHasProfilable.ProfilerBeginTick(); + TestProfiler.ProfilerBeginTick(); testProfiler.Send(); - TestHasProfilable.NotifyProfilerListeners(); + TestProfiler.NotifyProfilerListeners(); - BreakDownTestProfiler(useNullTransport); + Assert.IsTrue(testProfiler.HasSentAnyData); } [Test] public void TestDroppedRegisterAndNotifyFlow() { const bool useNullTransport = false; - TestHasProfilable testProfiler = SetupTestProfiler(useNullTransport); + TestProfiler testProfiler = SetupTestProfiler(useNullTransport); - TestHasProfilable.ProfilerBeginTick(); + RegisterStaticAsserts(useNullTransport); + + TestProfiler.ProfilerBeginTick(); testProfiler.Send(); - TestHasProfilable.NotifyProfilerListeners(); + TestProfiler.NotifyProfilerListeners(); // Capturing data after notifying listeners is bad Assert.Catch(() => @@ -152,41 +183,24 @@ public void TestDroppedRegisterAndNotifyFlow() { testProfiler.Send(); }); - TestHasProfilable.ProfilerBeginTick(); - BreakDownTestProfiler(useNullTransport); + Assert.IsTrue(testProfiler.HasSentAnyData); } - [Test] public void TestProperMatchRegisterAndNotifyFlow() { const bool useNullTransport = false; - TestHasProfilable testProfiler = SetupTestProfiler(useNullTransport); - - TestHasProfilable.NotifyProfilerListeners(); - TestHasProfilable.ProfilerBeginTick(); - testProfiler.Send(); - TestHasProfilable.NotifyProfilerListeners(); - - BreakDownTestProfiler(useNullTransport); - } + TestProfiler testProfiler = SetupTestProfiler(useNullTransport); - private static void TestProfilerOnPerformanceDataEventNormal(PerformanceTickData profilerData) - { - Assert.IsTrue(profilerData.HasData(TestHasProfilable.ProfilerConstants.NetworkTestData)); - Assert.IsTrue(profilerData.HasData(TestTransport.ProfilerConstants.TransportTestData)); - } + RegisterStaticAsserts(useNullTransport); - private static void TestProfilerOnPerformanceDataEventNoTransport(PerformanceTickData profilerData) - { - Assert.IsTrue(profilerData.HasData(TestHasProfilable.ProfilerConstants.NetworkTestData)); - Assert.IsFalse(profilerData.HasData(TestTransport.ProfilerConstants.TransportTestData)); - } + TestProfiler.NotifyProfilerListeners(); + TestProfiler.ProfilerBeginTick(); + testProfiler.Send(); + TestProfiler.NotifyProfilerListeners(); - private static void TestProfilerNotifierOnOnNoTickDataEvent() - { - throw new NoTickDataException(); + Assert.IsTrue(testProfiler.HasSentAnyData); } } } From 537067ccf19c0f5f6b74b3869d78f754d734f50f Mon Sep 17 00:00:00 2001 From: kvassall-unity Date: Tue, 23 Mar 2021 14:54:55 -0500 Subject: [PATCH 5/7] Cleaning up the tests some more --- com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs b/com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs index acc8bab262..bec89cb366 100644 --- a/com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs +++ b/com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs @@ -133,7 +133,7 @@ public void TestSentNoData() } [Test] - public void TestNormalRegisterAndNotifyFlowNull() + public void TestNormalRegisterAndNotifyFlow_NullTransport() { const bool useNullTransport = true; TestProfiler testProfiler = SetupTestProfiler(useNullTransport); @@ -179,10 +179,6 @@ public void TestDroppedRegisterAndNotifyFlow() { testProfiler.Send(); }); - Assert.Catch(() => - { - testProfiler.Send(); - }); Assert.IsTrue(testProfiler.HasSentAnyData); } From 93437ad1e7451fe22d7e88bbceda153406243170 Mon Sep 17 00:00:00 2001 From: kvassall-unity Date: Thu, 25 Mar 2021 09:47:29 -0500 Subject: [PATCH 6/7] More PR feedback --- .../Runtime/Core/NetworkManager.cs | 2 +- ...eTransport.cs => IProfilableTransportProvider.cs} | 2 +- ....cs.meta => IProfilableTransportProvider.cs.meta} | 0 .../Runtime/Profiling/ProfilerNotifier.cs | 12 ++++++------ 4 files changed, 8 insertions(+), 8 deletions(-) rename com.unity.multiplayer.mlapi/Runtime/Profiling/{IHasProfilableTransport.cs => IProfilableTransportProvider.cs} (64%) rename com.unity.multiplayer.mlapi/Runtime/Profiling/{IHasProfilableTransport.cs.meta => IProfilableTransportProvider.cs.meta} (100%) diff --git a/com.unity.multiplayer.mlapi/Runtime/Core/NetworkManager.cs b/com.unity.multiplayer.mlapi/Runtime/Core/NetworkManager.cs index 8e4a0e3fb1..6aa2affa9f 100644 --- a/com.unity.multiplayer.mlapi/Runtime/Core/NetworkManager.cs +++ b/com.unity.multiplayer.mlapi/Runtime/Core/NetworkManager.cs @@ -29,7 +29,7 @@ namespace MLAPI /// The main component of the library /// [AddComponentMenu("MLAPI/NetworkManager", -100)] - public class NetworkManager : MonoBehaviour, INetworkUpdateSystem, IHasProfilableTransport + public class NetworkManager : MonoBehaviour, INetworkUpdateSystem, IProfilableTransportProvider { [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] diff --git a/com.unity.multiplayer.mlapi/Runtime/Profiling/IHasProfilableTransport.cs b/com.unity.multiplayer.mlapi/Runtime/Profiling/IProfilableTransportProvider.cs similarity index 64% rename from com.unity.multiplayer.mlapi/Runtime/Profiling/IHasProfilableTransport.cs rename to com.unity.multiplayer.mlapi/Runtime/Profiling/IProfilableTransportProvider.cs index 861a5e619b..1776368e1d 100644 --- a/com.unity.multiplayer.mlapi/Runtime/Profiling/IHasProfilableTransport.cs +++ b/com.unity.multiplayer.mlapi/Runtime/Profiling/IProfilableTransportProvider.cs @@ -1,6 +1,6 @@ namespace MLAPI.Profiling { - public interface IHasProfilableTransport + public interface IProfilableTransportProvider { ITransportProfilerData Transport { get; } } diff --git a/com.unity.multiplayer.mlapi/Runtime/Profiling/IHasProfilableTransport.cs.meta b/com.unity.multiplayer.mlapi/Runtime/Profiling/IProfilableTransportProvider.cs.meta similarity index 100% rename from com.unity.multiplayer.mlapi/Runtime/Profiling/IHasProfilableTransport.cs.meta rename to com.unity.multiplayer.mlapi/Runtime/Profiling/IProfilableTransportProvider.cs.meta diff --git a/com.unity.multiplayer.mlapi/Runtime/Profiling/ProfilerNotifier.cs b/com.unity.multiplayer.mlapi/Runtime/Profiling/ProfilerNotifier.cs index 2962f3c558..4a20e0083b 100644 --- a/com.unity.multiplayer.mlapi/Runtime/Profiling/ProfilerNotifier.cs +++ b/com.unity.multiplayer.mlapi/Runtime/Profiling/ProfilerNotifier.cs @@ -13,21 +13,21 @@ public static class ProfilerNotifier public static event NoTickDataHandler OnNoTickDataEvent; - private static IHasProfilableTransport s_HasProfilableTransport; + private static IProfilableTransportProvider s_ProfilableTransportProvider; private static bool s_FailsafeCheck; - public static void Initialize(IHasProfilableTransport hasProfilableNetwork) + public static void Initialize(IProfilableTransportProvider profilableNetwork) { - s_HasProfilableTransport = hasProfilableNetwork + s_ProfilableTransportProvider = profilableNetwork ?? throw new ArgumentNullException( - $"{nameof(hasProfilableNetwork)} was not set"); + $"{nameof(profilableNetwork)} was not set"); s_FailsafeCheck = false; } public static void ProfilerBeginTick() { PerformanceDataManager.BeginNewTick(); - var transport = s_HasProfilableTransport.Transport; + var transport = s_ProfilableTransportProvider.Transport; transport?.BeginNewTick(); s_FailsafeCheck = true; } @@ -45,7 +45,7 @@ public static void NotifyProfilerListeners() { if (data != null) { - var transport = s_HasProfilableTransport.Transport; + var transport = s_ProfilableTransportProvider.Transport; if (transport != null) { var transportProfilerData = transport.GetTransportProfilerData(); From bee8bcaa2b7379cfc0fc1077cc0063afa5939635 Mon Sep 17 00:00:00 2001 From: kvassall-unity Date: Thu, 25 Mar 2021 10:07:07 -0500 Subject: [PATCH 7/7] More PR feedback --- com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs b/com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs index bec89cb366..77e0cee67e 100644 --- a/com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs +++ b/com.unity.multiplayer.mlapi/Tests/Editor/ProfilerTests.cs @@ -31,7 +31,7 @@ public void Send(string testMessage) } } - public class TestProfiler : IHasProfilableTransport + public class TestProfiler : IProfilableTransportProvider { internal static class ProfilerConstants {