Better multithread jobs generation tests
This commit is contained in:
parent
3e7575c4b2
commit
ffc19d4723
2 changed files with 47 additions and 10 deletions
|
|
@ -1510,7 +1510,8 @@ export struct EntityManager
|
|||
if (full_blocks_count * info.max_entities + entities_count + (
|
||||
first_block.entities_count - first_elem) >= entities_per_job)
|
||||
{
|
||||
assert(entities_per_job == full_blocks_count * info.max_entities + entities_count + (first_block.entities_count - first_elem));
|
||||
assert(entities_per_job == full_blocks_count * info.max_entities + entities_count + (
|
||||
first_block.entities_count - first_elem));
|
||||
CallData data = CallData(caller.system_id, sys,
|
||||
info, sys.m_update_delegate, first_block,
|
||||
cast(ushort)(full_blocks_count + 1),
|
||||
|
|
@ -1535,7 +1536,7 @@ export struct EntityManager
|
|||
first_elem = last_elem;
|
||||
blocks_count -= full_blocks_count + 1;
|
||||
first_block = block;
|
||||
if(last_elem == block.entities_count)
|
||||
if (last_elem == block.entities_count)
|
||||
{
|
||||
assert(block.next_block == null);
|
||||
first_block = null;
|
||||
|
|
@ -1553,7 +1554,7 @@ export struct EntityManager
|
|||
first_elem += last_elem;
|
||||
assert(first_elem <= first_block.entities_count);
|
||||
//if job takes every entity, take next block
|
||||
if(first_elem == first_block.entities_count)
|
||||
if (first_elem == first_block.entities_count)
|
||||
{
|
||||
first_elem = 0;
|
||||
first_block = first_block.next_block;
|
||||
|
|
|
|||
|
|
@ -897,7 +897,7 @@ unittest
|
|||
{
|
||||
struct TestSystem
|
||||
{
|
||||
mixin ECS.System;
|
||||
mixin ECS.System!64;
|
||||
|
||||
struct EntitiesData
|
||||
{
|
||||
|
|
@ -1003,15 +1003,51 @@ unittest
|
|||
assert(empty_system.update == 3);
|
||||
system.entities = 0;
|
||||
|
||||
foreach(i;0..10000)gEM.addEntity(tmpl);
|
||||
// foreach(i;0..10000)gEM.addEntity(tmpl);
|
||||
|
||||
// gEM.begin();
|
||||
|
||||
// gEM.updateMT("custom");
|
||||
|
||||
// gEM.end();
|
||||
|
||||
// assert(system.entities == 12001);
|
||||
|
||||
void clearEntities(TestSystem.EntitiesData data)
|
||||
{
|
||||
foreach(i;0..data.length)
|
||||
{
|
||||
gEM.removeEntity(data.entity[i].id);
|
||||
}
|
||||
}
|
||||
gEM.callEntitiesFunction!TestSystem(&clearEntities);
|
||||
gEM.commit();
|
||||
|
||||
foreach(i;0..2000)
|
||||
{
|
||||
gEM.addEntity(tmpl);
|
||||
|
||||
gEM.begin();
|
||||
|
||||
gEM.updateMT("custom");
|
||||
|
||||
gEM.end();
|
||||
|
||||
assert(system.entities == 12001);
|
||||
assert(system.entities == i+1);
|
||||
system.entities = 0;
|
||||
}
|
||||
|
||||
foreach(i;0..90000)gEM.addEntity(tmpl);
|
||||
|
||||
foreach(i;0..2000)
|
||||
{
|
||||
gEM.addEntity(tmpl);
|
||||
|
||||
gEM.begin();
|
||||
gEM.updateMT("custom");
|
||||
gEM.end();
|
||||
|
||||
assert(system.entities == i+92001);
|
||||
system.entities = 0;
|
||||
}
|
||||
}
|
||||
|
||||
unittest
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue