-
-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix allocation on tickables #279
Merged
hadashiA
merged 6 commits into
hadashiA:master
from
adarapata:fix_allocation_on_tickables
Jul 10, 2021
+128
−24
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2033a12
fix allocation on tickable loop
adarapata d24df81
fix post and fixed
adarapata fe8e907
fix all tickables
adarapata 37ad275
fix unnecessary spaces
adarapata 0a84e50
change argument
adarapata 559fb4a
Remove unnecessary intermediate variables.
adarapata File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
VContainer/Assets/VContainer/Tests/Unity/PlayerLoopItemTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
using System.Collections.Generic; | ||
using NUnit.Framework; | ||
using UnityEngine.TestTools.Constraints; | ||
using VContainer.Unity; | ||
using Is = NUnit.Framework.Is; | ||
|
||
namespace VContainer.Tests.Unity | ||
{ | ||
public class PlayerLoopItemTest | ||
{ | ||
private class Ticker : ITickable, IPostTickable, IPostLateTickable, IFixedTickable, IPostFixedTickable | ||
{ | ||
public void Tick() { } | ||
public void FixedTick() { } | ||
public void PostTick() { } | ||
public void PostLateTick() { } | ||
public void PostFixedTick() { } | ||
} | ||
|
||
private class TickableLoopItemTest | ||
{ | ||
[Test] | ||
public void MoveNextWithoutAllocation() | ||
{ | ||
var list = new List<ITickable> { new Ticker(), new Ticker() }; | ||
var exceptionHandler = new EntryPointExceptionHandler(exception => { }); | ||
var tickableLoopItem = new TickableLoopItem(list, exceptionHandler); | ||
|
||
Assert.That(() => | ||
{ | ||
tickableLoopItem.MoveNext(); | ||
}, Is.Not.AllocatingGCMemory()); | ||
} | ||
} | ||
|
||
private class PostTickableLoopItemTest | ||
{ | ||
[Test] | ||
public void MoveNextWithoutAllocation() | ||
{ | ||
var list = new List<IPostTickable> { new Ticker(), new Ticker() }; | ||
var exceptionHandler = new EntryPointExceptionHandler(exception => { }); | ||
var tickableLoopItem = new PostTickableLoopItem(list, exceptionHandler); | ||
|
||
Assert.That(() => | ||
{ | ||
tickableLoopItem.MoveNext(); | ||
}, Is.Not.AllocatingGCMemory()); | ||
} | ||
} | ||
|
||
private class PostLateTickableLoopItemTest | ||
{ | ||
[Test] | ||
public void MoveNextWithoutAllocation() | ||
{ | ||
var list = new List<IPostLateTickable> { new Ticker(), new Ticker() }; | ||
var exceptionHandler = new EntryPointExceptionHandler(exception => { }); | ||
var tickableLoopItem = new PostLateTickableLoopItem(list, exceptionHandler); | ||
|
||
Assert.That(() => | ||
{ | ||
tickableLoopItem.MoveNext(); | ||
}, Is.Not.AllocatingGCMemory()); | ||
} | ||
} | ||
|
||
private class FixedTickableLoopItemTest | ||
{ | ||
[Test] | ||
public void MoveNextWithoutAllocation() | ||
{ | ||
var list = new List<IFixedTickable> { new Ticker(), new Ticker() }; | ||
var exceptionHandler = new EntryPointExceptionHandler(exception => { }); | ||
var tickableLoopItem = new FixedTickableLoopItem(list, exceptionHandler); | ||
|
||
Assert.That(() => | ||
{ | ||
tickableLoopItem.MoveNext(); | ||
}, Is.Not.AllocatingGCMemory()); | ||
} | ||
} | ||
|
||
private class PostFixedTickableLoopItemTest | ||
{ | ||
[Test] | ||
public void MoveNextWithoutAllocation() | ||
{ | ||
var list = new List<IPostFixedTickable> { new Ticker(), new Ticker() }; | ||
var exceptionHandler = new EntryPointExceptionHandler(exception => { }); | ||
var tickableLoopItem = new PostFixedTickableLoopItem(list, exceptionHandler); | ||
|
||
Assert.That(() => | ||
{ | ||
tickableLoopItem.MoveNext(); | ||
}, Is.Not.AllocatingGCMemory()); | ||
} | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
VContainer/Assets/VContainer/Tests/Unity/PlayerLoopItemTest.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍