Skip to content

Commit

Permalink
Tests - add BoostedQuery() example
Browse files Browse the repository at this point in the history
  • Loading branch information
friflo committed Aug 9, 2024
1 parent 34a3426 commit 4436d14
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Tests/ECS/Examples/HelloWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
// ReSharper disable UnusedParameter.Local
// ReSharper disable CheckNamespace
namespace Tests.Examples {

public struct Velocity : IComponent { public Vector3 value; }

// See: https://github.com/friflo/Friflo.Engine.ECS#-examples
public static class HelloWorldExample
{

public struct Velocity : IComponent { public Vector3 value; }

[Test]
public static void HelloWorld()
{
Expand Down
21 changes: 20 additions & 1 deletion src/Tests/ECS/Examples/Optimization.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using System;
using System.Numerics;
using Friflo.Engine.ECS;
using NUnit.Framework;
using static Tests.Examples.General;

#if !UNITY_5_3_OR_NEWER
using System.Runtime.Intrinsics;

#endif

// ReSharper disable ArrangeTypeMemberModifiers
// ReSharper disable UnusedVariable
// ReSharper disable UnusedParameter.Local
// ReSharper disable CheckNamespace
Expand All @@ -17,6 +18,24 @@ namespace Tests.Examples {
public static class Optimization
{

[Test]
public static void BoostedQuery()
{
var store = new EntityStore();
for (int n = 0; n < 100; n++) {
store.CreateEntity(new Position(n, 0, 0), new Velocity{ value = new Vector3(0, n, 0)});
}
var query = store.Query<Position, Velocity>();
query.Each(new MoveEach()); // requires https://www.nuget.org/packages/Friflo.Engine.ECS.Boost
}

struct MoveEach : IEach<Position, Velocity>
{
public void Execute(ref Position position, ref Velocity velocity) {
position.value += velocity.value;
}
}

[Test]
public static void EnumerateQueryChunks()
{
Expand Down

0 comments on commit 4436d14

Please sign in to comment.