refactor: Building out a test to get some surface coverage of the mlapi p…#646
Conversation
becksebenius-unity
left a comment
There was a problem hiding this comment.
I don't see any red flags but waiting for replies before approve
| { | ||
| s_TickId = Math.Max(s_TickId, 0); | ||
| s_TickId++; | ||
| s_ProfilerData = new PerformanceTickData |
There was a problem hiding this comment.
you'll need to update this after the release->dev merge
There was a problem hiding this comment.
hey @becksebenius-unity & @kvassall-unity — we had release to develop merge recently, so what's up? :)
There was a problem hiding this comment.
Updated and rebased @MFatihMAR
| testProfiler.Send(); | ||
| TestHasProfilable.NotifyProfilerListeners(); | ||
|
|
||
| BreakDownTestProfiler(useNullTransport); |
There was a problem hiding this comment.
You should use a [Teardown] method instead of the tailed method call here, otherwise an exception in a single test will leave it in a bad state
| } | ||
|
|
||
| [Test] | ||
| public void TestNormalRegisterAndNotifyFlow() |
There was a problem hiding this comment.
About this test, and TestNormalRegisterAndNotifyFlowNull, there's no asserts in the test and the method name doesn't describe how it could fail - if this test were to fail on me due to some work I was doing, it would be hard for me to decipher what the intent of the test was. If at all possible I'd recommend adding explicit asserts for the fail cases you're testing
…rofiler functionality
…t MLAPI could use directly
cf766b0 to
537067c
Compare
|
|
||
| NetworkConfig.NetworkTransport.Init(); | ||
|
|
||
| ProfilerNotifier.Initialize(this); |
There was a problem hiding this comment.
Is this something we always do even if we're not running in the editor? Or put another way, what if I'm shipping the game and don't want the profiler overhead?
There was a problem hiding this comment.
In the same vein, in NetworkProfiler.cs circa line 651 (and I know this is from a previous commit) we unconditionally call ProfilerBeginTick
There was a problem hiding this comment.
So this was an intentional choice on our end, since there may be runtime tools that need this data. That doesn't mean users might not want to omit the profiling from the build, but we haven't provided that utility yet. Since we're just tracking counters in v1 the overhead is very small, but as we expand the data set this is going to be important. Maybe we could add a #if !MLAPI_DISABLE_STATS so that it's on by default, but users can turn it off with the compiler configuration.
I'd suggest that this belongs in a separate PR though. Kamau isn't introducing profiling into release builds with this PR, he's just refactoring functionality that already exists.
| internal static void BeginNewTick() | ||
| { | ||
| s_TickId = Math.Max(s_TickId, 0); | ||
| s_TickId++; |
There was a problem hiding this comment.
Looks like a bugfix? Nice.
mattwalsh-unity
left a comment
There was a problem hiding this comment.
Would like to bottom out on when profiling code should be active / disabled
| @@ -0,0 +1,7 @@ | |||
| namespace MLAPI.Profiling | |||
| { | |||
| public interface IHasProfilableTransport | |||
There was a problem hiding this comment.
what about IProfilableTransport, ITransportProfileProvider or ITransportProfileSource etc.? @kvassall-unity @becksebenius-unity — I'm just trying to nit-pick on the "Has" part :D
There was a problem hiding this comment.
I don't mind the Has personally, but it does sound gramatically awkward - what about IProfilableTransportProvider (kind of a combination of your suggestions)
|
|
||
| namespace MLAPI.Profiling | ||
| { | ||
| public static class ProfilerNotifier |
There was a problem hiding this comment.
so obviously this PR introduces stuff more than just tests right?
There was a problem hiding this comment.
I agree, originally the PR was just tests but should probably update the commit message to refactor with the expanded scope
becksebenius-unity
left a comment
There was a problem hiding this comment.
Updates to the tests look good to me, I understand the code isn't well suited to top-level asserts (yet?). Marking request changes, just semantics but I agree with Fatih that this should be a refactor: now instead of test:. Otherwise lgtm
@becksebenius-unity Which changes were you waiting on? the title change or something specific? |
Sorry it wasn't clear, my "requested change" was to update the PR description. Marking approve now |
…rofiler functionality