-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
38 additions
and
3 deletions.
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
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,35 @@ | ||
using System; | ||
using Friflo.Engine.ECS; | ||
using NUnit.Framework; | ||
using Tests.Utils; | ||
|
||
// ReSharper disable InconsistentNaming | ||
namespace Tests.ECS.Github | ||
{ | ||
/// https://github.com/friflo/Friflo.Engine.ECS/issues/47 | ||
public static class Test_GitHub_47 | ||
{ | ||
[Test] | ||
public static void Parallel_QueryJob_using_AsSpan() | ||
{ | ||
const int threads = 2; | ||
Console.WriteLine("Threads count: "+ threads); | ||
var runner = new ParallelJobRunner(threads); | ||
var store = new EntityStore() {JobRunner = runner}; | ||
for (int n = 0; n < 64; n++) { | ||
store.CreateEntity(new MyComponent1 { a = n }); | ||
} | ||
|
||
var query = store.Query<MyComponent1>(); | ||
var queryJob = query.ForEach((chunk, _) => | ||
{ | ||
Span<int> values = chunk.AsSpan256<int>(); | ||
for (int i = 0; i < values.Length; i++) { | ||
Mem.AreEqual(chunk[i].a, values[i]); | ||
} | ||
}); | ||
queryJob.MinParallelChunkLength = 16; | ||
queryJob.RunParallel(); | ||
} | ||
} | ||
} |