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() { 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.Run(query); 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(); }