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 + (
|
if (full_blocks_count * info.max_entities + entities_count + (
|
||||||
first_block.entities_count - first_elem) >= entities_per_job)
|
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,
|
CallData data = CallData(caller.system_id, sys,
|
||||||
info, sys.m_update_delegate, first_block,
|
info, sys.m_update_delegate, first_block,
|
||||||
cast(ushort)(full_blocks_count + 1),
|
cast(ushort)(full_blocks_count + 1),
|
||||||
|
|
|
||||||
|
|
@ -897,7 +897,7 @@ unittest
|
||||||
{
|
{
|
||||||
struct TestSystem
|
struct TestSystem
|
||||||
{
|
{
|
||||||
mixin ECS.System;
|
mixin ECS.System!64;
|
||||||
|
|
||||||
struct EntitiesData
|
struct EntitiesData
|
||||||
{
|
{
|
||||||
|
|
@ -1003,15 +1003,51 @@ unittest
|
||||||
assert(empty_system.update == 3);
|
assert(empty_system.update == 3);
|
||||||
system.entities = 0;
|
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.begin();
|
||||||
|
|
||||||
gEM.updateMT("custom");
|
gEM.updateMT("custom");
|
||||||
|
|
||||||
gEM.end();
|
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
|
unittest
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue