Skip to content
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

Revert "QuadTree Performance Tuning" #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build, Pack & Publish
on:
push:
branches:
- 'master'
- '*'
tags:
- 'v*'
pull_request:
Expand All @@ -24,7 +24,7 @@ jobs:
- name: Install .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.*
dotnet-version: 6.0.*
source-url: https://api.nuget.org/v3/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
Expand Down
6 changes: 3 additions & 3 deletions src/DtronixCommon.Tests/BoundaryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ public class BoundaryTests
[Test]
public void OneDimensionalBoundaryIsNotEmpty()
{
Assert.That(new BoundaryF(0, -1, 0, 1).IsEmpty, Is.False);
Assert.That(new BoundaryF(-1, 0, 1, 0).IsEmpty, Is.False);
Assert.IsFalse(new BoundaryF(0, -1, 0, 1).IsEmpty);
Assert.IsFalse(new BoundaryF(-1, 0, 1, 0).IsEmpty);
}

[Test]
public void CanUnionBoundariesWithOneDimension()
{
Assert.That(new BoundaryF(0, -1, 0, 1).Union(new BoundaryF(-1, 0, 1, 0)), Is.EqualTo(new BoundaryF(-1, -1, 1, 1)));
Assert.AreEqual(new BoundaryF(-1, -1, 1, 1), new BoundaryF(0, -1, 0, 1).Union(new BoundaryF(-1, 0, 1, 0)));
}
}
84 changes: 42 additions & 42 deletions src/DtronixCommon.Tests/Collections/BufferSequenceTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using DtronixCommon.Collections;
using NUnit.Framework;
Expand All @@ -9,44 +9,44 @@ public class BufferSequenceTests
{
private void VerifySequence(BufferSequence.Range range, int expectedStart, int expectedEnd)
{
Assert.That(range.Start, Is.EqualTo(expectedStart), "Start");
Assert.That(range.End, Is.EqualTo(expectedEnd), "End");
Assert.AreEqual(expectedStart, range.Start, "Start");
Assert.AreEqual(expectedEnd, range.End, "End");
}

[Test]
public void HeadIndexResets()
{
var bs = new BufferSequence(9);

Assert.That(bs.Rent(), Is.GreaterThan(-1));
Assert.That(bs.Rent(), Is.GreaterThan(-1));
Assert.Greater(bs.Rent(), -1);
Assert.Greater(bs.Rent(), -1);

Assert.That(bs.HeadIndex, Is.EqualTo(0));
Assert.AreEqual(0, bs.HeadIndex);
bs.Return(0);
Assert.That(bs.HeadIndex, Is.EqualTo(1));
Assert.AreEqual(1, bs.HeadIndex);
}

[Test]
public void HeadIsRentedAfterReturn()
{
var bs = new BufferSequence(9);
for (int i = 0; i < 10; i++)
Assert.That(bs.Rent(), Is.GreaterThan(-1));
Assert.Greater(bs.Rent(), -1);

bs.Return(0);
Assert.That(bs.Rent(), Is.EqualTo(0));
Assert.AreEqual(0, bs.Rent());
}

[Test]
public void TailIsTrimmed()
{
var bs = new BufferSequence(9);
for (int i = 0; i < 10; i++)
Assert.That(bs.Rent(), Is.GreaterThan(-1));
Assert.Greater(bs.Rent(), -1);

Assert.That(bs.ConsumedTailIndex, Is.EqualTo(9));
Assert.AreEqual(9, bs.ConsumedTailIndex);
bs.Return(9);
Assert.That(bs.ConsumedTailIndex, Is.EqualTo(8));
Assert.AreEqual(8, bs.ConsumedTailIndex);
}

[Test]
Expand All @@ -56,7 +56,7 @@ public void TailIsReused()
for (int i = 0; i < 10; i++)
bs.Rent();
bs.Return(9);
Assert.That(bs.Rent(), Is.EqualTo(9));
Assert.AreEqual(9, bs.Rent());
}

[Test]
Expand All @@ -65,15 +65,15 @@ public void RentsInOrder()
var bs = new BufferSequence(9);
var value = bs.Rent();
var value2 = bs.Rent();
Assert.That(value, Is.EqualTo(0));
Assert.That(value2, Is.EqualTo(1));
Assert.That(bs.Rent(), Is.EqualTo(2));
Assert.AreEqual(0, value);
Assert.AreEqual(1, value2);
Assert.AreEqual(2, bs.Rent());

bs.Return(value);
Assert.That(bs.Rent(), Is.EqualTo(0));
Assert.AreEqual(0, bs.Rent());

bs.Return(value2);
Assert.That(bs.Rent(), Is.EqualTo(1));
Assert.AreEqual(1, bs.Rent());
}

[Test]
Expand All @@ -83,7 +83,7 @@ public void RentReturnsFull()
for (int i = 0; i < 11; i++)
bs.Rent();

Assert.That(bs.Rent(), Is.EqualTo(-1));
Assert.AreEqual(-1, bs.Rent());
}

[Test]
Expand All @@ -95,7 +95,7 @@ public void ReturnFullSequence()

var result = bs.RentedSequences().ToArray();

Assert.That(result, Has.Length.EqualTo(1));
Assert.AreEqual(1, result.Length);
VerifySequence(result[0], 0, 10);
}

Expand All @@ -107,7 +107,7 @@ public void StopsRentingWhenFull()
for (int i = 0; i < 10; i++)
items.Add(bs.Rent());

Assert.That(bs.Rent(), Is.EqualTo(-1));
Assert.AreEqual(-1 , bs.Rent());
}

[Test]
Expand All @@ -120,7 +120,7 @@ public void ReturnFullSequenceWithGapAtStart()
bs.Return(0);
var result = bs.RentedSequences().ToArray();

Assert.That(result, Has.Length.EqualTo(1));
Assert.AreEqual(1, result.Length);
VerifySequence(result[0], 1, 10);
}

Expand All @@ -134,7 +134,7 @@ public void ReturnFullSequenceWithGapAtEnd()
bs.Return(9);
var result = bs.RentedSequences().ToArray();

Assert.That(result, Has.Length.EqualTo(1));
Assert.AreEqual(1, result.Length);
VerifySequence(result[0], 0, 8);
}

Expand All @@ -150,12 +150,12 @@ public void ReturnGappedSequence()
bs.Return(i);
var result = bs.RentedSequences().ToArray();

Assert.That(result, Has.Length.EqualTo(2));
Assert.AreEqual(2, result.Length);

VerifySequence(result[0], 0, i - 1);

VerifySequence(result[1], i + 1, 9);
Assert.That(bs.Rent(), Is.EqualTo(i));
Assert.AreEqual(i, bs.Rent());
}
}

Expand All @@ -174,7 +174,7 @@ public void ReturnMultiGappedSequence()

var result = bs.RentedSequences().ToArray();

Assert.That(result, Has.Length.EqualTo(5));
Assert.AreEqual(5, result.Length);

VerifySequence(result[0], 0, 0);
VerifySequence(result[1], 2, 2);
Expand All @@ -188,19 +188,19 @@ public void RentRetrievesInOrder()
{
var bs = new BufferSequence(9);
for (int i = 0; i < 10; i++)
Assert.That(bs.Rent(), Is.GreaterThan(-1));
Assert.Greater(bs.Rent(), -1);

bs.Return(9);
bs.Return(3);
bs.Return(1);
bs.Return(7);
bs.Return(5);

Assert.That(bs.Rent(), Is.EqualTo(1));
Assert.That(bs.Rent(), Is.EqualTo(3));
Assert.That(bs.Rent(), Is.EqualTo(5));
Assert.That(bs.Rent(), Is.EqualTo(7));
Assert.That(bs.Rent(), Is.EqualTo(9));
Assert.AreEqual(1, bs.Rent());
Assert.AreEqual(3, bs.Rent());
Assert.AreEqual(5, bs.Rent());
Assert.AreEqual(7, bs.Rent());
Assert.AreEqual(9, bs.Rent());
}


Expand All @@ -217,7 +217,7 @@ public void ReleaseCullsContinuousGaps()

var result = bs.RentedSequences().ToArray();

Assert.That(result, Has.Length.EqualTo(2));
Assert.AreEqual(2, result.Length);
VerifySequence(result[0], 0, 3);
VerifySequence(result[1], 7, 9);
}
Expand All @@ -234,11 +234,11 @@ public void ReleaseCullsContinuousGapsAtEnd()
bs.Return(7);
bs.Return(8);

Assert.That(bs.ConsumedTailIndex, Is.EqualTo(9));
Assert.AreEqual(9, bs.ConsumedTailIndex);

bs.Return(9);

Assert.That(bs.ConsumedTailIndex, Is.EqualTo(6));
Assert.AreEqual(6, bs.ConsumedTailIndex);
}

[Test]
Expand All @@ -253,23 +253,23 @@ public void ReleaseCullsContinuousGapsAtEndAndUpdatesAvailableCount()
bs.Return(7);
bs.Return(8);

Assert.That(bs.AvailableCount, Is.EqualTo(3));
Assert.AreEqual(3, bs.AvailableCount);

bs.Return(9);

Assert.That(bs.AvailableCount, Is.EqualTo(4));
Assert.AreEqual(4, bs.AvailableCount);
}

[Test]
public void ReturningLastBufferResets()
{
var bs = new BufferSequence(9);
bs.Rent();
Assert.That(bs.HeadIndex, Is.EqualTo(0));
Assert.That(bs.ConsumedTailIndex, Is.EqualTo(0));
Assert.AreEqual(0, bs.HeadIndex);
Assert.AreEqual(0, bs.ConsumedTailIndex);
bs.Return(0);
Assert.That(bs.Returned.count, Is.EqualTo(0));
Assert.That(bs.ConsumedTailIndex, Is.EqualTo(-1));
Assert.AreEqual(0, bs.Returned.count);
Assert.AreEqual(-1, bs.ConsumedTailIndex);

}
}
}
40 changes: 20 additions & 20 deletions src/DtronixCommon.Tests/Collections/SimpleLinkedListTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ public void BreakNodeAfter()
nodes[i] = linkedList.AddLast(i);


Assert.That(linkedList.Count, Is.EqualTo(5));
Assert.That(linkedList.Last, Is.EqualTo(nodes.Last()));
Assert.AreEqual(5, linkedList.Count);
Assert.AreEqual(nodes.Last(), linkedList.Last);

linkedList.BreakAtNode(nodes[2], true);

Assert.That(linkedList.Count, Is.EqualTo(2));
Assert.That(linkedList.Last, Is.EqualTo(nodes[1]));
Assert.AreEqual(2, linkedList.Count);
Assert.AreEqual(nodes[1], linkedList.Last);
}

[Test]
Expand All @@ -33,13 +33,13 @@ public void BreakNodeBefore()
for (int i = 0; i < nodes.Length; i++)
nodes[i] = linkedList.AddLast(i);

Assert.That(linkedList.Count, Is.EqualTo(5));
Assert.That(linkedList.Last, Is.EqualTo(nodes.Last()));
Assert.AreEqual(5, linkedList.Count);
Assert.AreEqual(nodes.Last(), linkedList.Last);

linkedList.BreakAtNode(nodes[2], false);

Assert.That(linkedList.Count, Is.EqualTo(2));
Assert.That(linkedList.Last, Is.EqualTo(nodes[3]));
Assert.AreEqual(2, linkedList.Count);
Assert.AreEqual(nodes[3], linkedList.Last);
}


Expand All @@ -53,9 +53,9 @@ public void BreakNodeBeforeAtStart()

linkedList.BreakAtNode(nodes[0], false);

Assert.That(linkedList.Count, Is.EqualTo(4));
Assert.That(linkedList.First, Is.EqualTo(nodes[1]));
Assert.That(linkedList.Last, Is.EqualTo(nodes[4]));
Assert.AreEqual(4, linkedList.Count);
Assert.AreEqual(nodes[1], linkedList.First);
Assert.AreEqual(nodes[4], linkedList.Last);
}

[Test]
Expand All @@ -68,9 +68,9 @@ public void BreakNodeBeforeAtEnd()

linkedList.BreakAtNode(nodes[4], true);

Assert.That(linkedList.Count, Is.EqualTo(4));
Assert.That(linkedList.First, Is.EqualTo(nodes[0]));
Assert.That(linkedList.Last, Is.EqualTo(nodes[3]));
Assert.AreEqual(4, linkedList.Count);
Assert.AreEqual(nodes[0], linkedList.First);
Assert.AreEqual(nodes[3], linkedList.Last);
}

[Test]
Expand All @@ -83,9 +83,9 @@ public void BreakThreeItemNodeListAfter()

linkedList.BreakAtNode(nodes[1], true);

Assert.That(linkedList.Count, Is.EqualTo(1));
Assert.That(linkedList.First, Is.EqualTo(nodes[0]));
Assert.That(linkedList.Last, Is.EqualTo(nodes[0]));
Assert.AreEqual(1, linkedList.Count);
Assert.AreEqual(nodes[0], linkedList.First);
Assert.AreEqual(nodes[0], linkedList.Last);
}
[Test]
public void BreakThreeItemNodeListBefore()
Expand All @@ -97,8 +97,8 @@ public void BreakThreeItemNodeListBefore()

linkedList.BreakAtNode(nodes[1], false);

Assert.That(linkedList.Count, Is.EqualTo(1));
Assert.That(linkedList.First, Is.EqualTo(nodes[2]));
Assert.That(linkedList.Last, Is.EqualTo(nodes[2]));
Assert.AreEqual(1, linkedList.Count);
Assert.AreEqual(nodes[2], linkedList.First);
Assert.AreEqual(nodes[2], linkedList.Last);
}
}
Loading
Loading