Skip to content

refactor: Building out a test to get some surface coverage of the mlapi p…#646

Merged
kvassall-unity merged 8 commits intodevelopfrom
feature/initial_barebones_proflier_test
Mar 25, 2021
Merged

refactor: Building out a test to get some surface coverage of the mlapi p…#646
kvassall-unity merged 8 commits intodevelopfrom
feature/initial_barebones_proflier_test

Conversation

@kvassall-unity
Copy link
Copy Markdown
Contributor

…rofiler functionality

Copy link
Copy Markdown
Contributor

@becksebenius-unity becksebenius-unity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'll need to update this after the release->dev merge

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @becksebenius-unity & @kvassall-unity — we had release to develop merge recently, so what's up? :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated and rebased @MFatihMAR

testProfiler.Send();
TestHasProfilable.NotifyProfilerListeners();

BreakDownTestProfiler(useNullTransport);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@kvassall-unity kvassall-unity force-pushed the feature/initial_barebones_proflier_test branch from cf766b0 to 537067c Compare March 23, 2021 22:01

NetworkConfig.NetworkTransport.Init();

ProfilerNotifier.Initialize(this);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the same vein, in NetworkProfiler.cs circa line 651 (and I know this is from a previous commit) we unconditionally call ProfilerBeginTick

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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++;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a bugfix? Nice.

Copy link
Copy Markdown
Contributor

@mattwalsh-unity mattwalsh-unity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would like to bottom out on when profiling code should be active / disabled

@@ -0,0 +1,7 @@
namespace MLAPI.Profiling
{
public interface IHasProfilableTransport
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about IProfilableTransport, ITransportProfileProvider or ITransportProfileSource etc.? @kvassall-unity @becksebenius-unity — I'm just trying to nit-pick on the "Has" part :D

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind the Has personally, but it does sound gramatically awkward - what about IProfilableTransportProvider (kind of a combination of your suggestions)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good to me! :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


namespace MLAPI.Profiling
{
public static class ProfilerNotifier
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so obviously this PR introduces stuff more than just tests right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, originally the PR was just tests but should probably update the commit message to refactor with the expanded scope

Copy link
Copy Markdown
Contributor

@becksebenius-unity becksebenius-unity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@kvassall-unity kvassall-unity changed the title test: Building out a test to get some surface coverage of the mlapi p… refactor: Building out a test to get some surface coverage of the mlapi p… Mar 24, 2021
@kvassall-unity
Copy link
Copy Markdown
Contributor Author

kvassall-unity commented Mar 25, 2021

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?

@becksebenius-unity
Copy link
Copy Markdown
Contributor

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

@kvassall-unity kvassall-unity merged commit 1e650bb into develop Mar 25, 2021
@kvassall-unity kvassall-unity deleted the feature/initial_barebones_proflier_test branch March 25, 2021 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants