public void TestSimpleIJobChunk([Values(0, 1, 2, 3)] int mode, [Values(1, 100)] int n) { NativeArray <Entity> eArr = new NativeArray <Entity>(n, Allocator.TempJob); var arch = m_Manager.CreateArchetype(typeof(EcsTestData)); m_Manager.CreateEntity(arch, eArr); for (int i = 0; i < n; ++i) { m_Manager.SetComponentData(eArr[i], new EcsTestData() { value = 10 + i }); } NativeList <int> listOfInt = new NativeList <int>(1, Allocator.TempJob); EntityQuery query = EmptySystem.GetEntityQuery(typeof(EcsTestData)); var job = new SimpleChunk <int> { testType = m_Manager.GetArchetypeChunkComponentType <EcsTestData>(false), listOfT = listOfInt }; switch (mode) { case 0: job.Schedule(query).Complete(); break; case 1: job.ScheduleParallel(query).Complete(); break; case 2: job.ScheduleSingle(query).Complete(); break; case 3: job.Run(query); break; } for (int i = 0; i < n; ++i) { EcsTestData data = m_Manager.GetComponentData <EcsTestData>(eArr[i]); Assert.AreEqual(10 + i + 100, data.value); } listOfInt.Dispose(); eArr.Dispose(); }
public void RunSimpleIJobChunk() { didDispose = 0; const int N = 10000 * NMULT; NativeArray <Entity> eArr = new NativeArray <Entity>(N, Allocator.TempJob); var arch = m_Manager.CreateArchetype(typeof(EcsTestData)); m_Manager.CreateEntity(arch, eArr); for (int i = 0; i < N; ++i) { m_Manager.SetComponentData(eArr[i], new EcsTestData() { value = 10 + i }); } EntityQuery query = EmptySystem.GetEntityQuery(typeof(EcsTestData)); var job = new SimpleChunk { testType = m_Manager.GetArchetypeChunkComponentType <EcsTestData>(false) }; job.Schedule(query).Complete(); #if !UNITY_DOTSPLAYER // TODO: Understand / fix why the editor tests don't run quite the same code path. job.mDisposable.Dispose(); #endif for (int i = 0; i < N; ++i) { EcsTestData data = m_Manager.GetComponentData <EcsTestData>(eArr[i]); Assert.AreEqual(data.value, 10 + i + 100); } Assert.AreEqual(1, didDispose); eArr.Dispose(); }
public void ScheduleSimpleIJobChunk() { const int N = 10000 * NMULT; NativeArray <Entity> eArr = new NativeArray <Entity>(N, Allocator.TempJob); var arch = m_Manager.CreateArchetype(typeof(EcsTestData)); m_Manager.CreateEntity(arch, eArr); for (int i = 0; i < N; ++i) { m_Manager.SetComponentData(eArr[i], new EcsTestData() { value = 10 + i }); } NativeList <int> listOfInt = new NativeList <int>(1, Allocator.TempJob); EntityQuery query = EmptySystem.GetEntityQuery(typeof(EcsTestData)); var job = new SimpleChunk <int> { testType = m_Manager.GetArchetypeChunkComponentType <EcsTestData>(false), listOfT = listOfInt }; job.Schedule(query).Complete(); for (int i = 0; i < N; ++i) { EcsTestData data = m_Manager.GetComponentData <EcsTestData>(eArr[i]); Assert.AreEqual(10 + i + 100, data.value); } listOfInt.Dispose(); eArr.Dispose(); }
public void RunSimpleIJobChunk() { didDispose = 0; const int N = 10 * 1000; NativeArray <Entity> eArr = new NativeArray <Entity>(N, Allocator.TempJob); var arch = m_Manager.CreateArchetype(typeof(EcsTestData)); m_Manager.CreateEntity(arch, eArr); for (int i = 0; i < N; ++i) { m_Manager.SetComponentData(eArr[i], new EcsTestData() { value = 10 + i }); } EntityQuery query = EmptySystem.GetEntityQuery(typeof(EcsTestData)); var job = new SimpleChunk { testType = m_Manager.GetArchetypeChunkComponentType <EcsTestData>(false) }; job.Schedule(query).Complete(); for (int i = 0; i < N; ++i) { EcsTestData data = m_Manager.GetComponentData <EcsTestData>(eArr[i]); Assert.AreEqual(data.value, 10 + i + 100); } #if NET_DOTS Assert.AreEqual(1, didDispose); #endif eArr.Dispose(); }