-update README code example (to one that compile)

-remove Entity.instance and gEM, global manager is now gEntityManager
This commit is contained in:
Mergul 2021-03-02 19:44:18 +01:00
parent d1c48e4c5f
commit 3b954b732b
11 changed files with 617 additions and 604 deletions

View file

@ -63,123 +63,123 @@ EntityTemplate* tmpl;
void beforeEveryTest()
{
gEM.initialize(0);
gEntityManager.initialize(0);
gEM.beginRegister();
gEntityManager.beginRegister();
gEM.registerComponent!CLong;
gEM.registerComponent!CShort;
gEM.registerComponent!CInt;
gEM.registerComponent!CUInt;
gEM.registerComponent!CBig;
gEntityManager.registerComponent!CLong;
gEntityManager.registerComponent!CShort;
gEntityManager.registerComponent!CInt;
gEntityManager.registerComponent!CUInt;
gEntityManager.registerComponent!CBig;
gEM.endRegister();
gEntityManager.endRegister();
tmpl = null;
}
void afterEveryTest()
{
if(tmpl)gEM.freeTemplate(tmpl);
if(tmpl)gEntityManager.freeTemplate(tmpl);
tmpl = null;
gEM.destroy();
gEntityManager.destroy();
}
void smallTmpl()
{
tmpl = gEM.allocateTemplate([becsID!CShort].staticArray);
tmpl = gEntityManager.allocateTemplate([becsID!CShort].staticArray);
}
void bigTmpl()
{
tmpl = gEM.allocateTemplate([becsID!CBig].staticArray);
tmpl = gEntityManager.allocateTemplate([becsID!CBig].staticArray);
}
void multiSmallTmpl()
{
tmpl = gEM.allocateTemplate([becsID!CShort, becsID!CLong, becsID!CInt, becsID!CUInt].staticArray);
tmpl = gEntityManager.allocateTemplate([becsID!CShort, becsID!CLong, becsID!CInt, becsID!CUInt].staticArray);
}
void multiBigTmpl()
{
tmpl = gEM.allocateTemplate([becsID!CLong, becsID!CInt, becsID!CUInt, becsID!CBig].staticArray);
tmpl = gEntityManager.allocateTemplate([becsID!CLong, becsID!CInt, becsID!CUInt, becsID!CBig].staticArray);
}
@("AddEntities100k1comp2b") @(before, &smallTmpl)
unittest
{
foreach(i; 0..100_000)gEM.addEntity(tmpl);
foreach(i; 0..100_000)gEntityManager.addEntity(tmpl);
}
@("AddEntities100k1comp128b") @(before, &bigTmpl)
unittest
{
foreach(i; 0..100_000)gEM.addEntity(tmpl);
foreach(i; 0..100_000)gEntityManager.addEntity(tmpl);
}
@("AddEntities100k4comp18b") @(before, &multiSmallTmpl)
unittest
{
foreach(i; 0..100_000)gEM.addEntity(tmpl);
foreach(i; 0..100_000)gEntityManager.addEntity(tmpl);
}
@("AddEntities100k4comp144b") @(before, &multiBigTmpl)
unittest
{
foreach(i; 0..100_000)gEM.addEntity(tmpl);
foreach(i; 0..100_000)gEntityManager.addEntity(tmpl);
}
void allocDealloc100k()
{
foreach(i; 0..100_000)gEM.addEntity(tmpl);
gEM.commit();
foreach(i; 0..100_000)gEM.removeEntity(EntityID(i + 1,0));
gEM.commit();
foreach(i; 0..100_000)gEntityManager.addEntity(tmpl);
gEntityManager.commit();
foreach(i; 0..100_000)gEntityManager.removeEntity(EntityID(i + 1,0));
gEntityManager.commit();
}
void smallTmplPreAlloc()
{
tmpl = gEM.allocateTemplate([becsID!CShort].staticArray);
tmpl = gEntityManager.allocateTemplate([becsID!CShort].staticArray);
allocDealloc100k();
}
void bigTmplPreAlloc()
{
tmpl = gEM.allocateTemplate([becsID!CBig].staticArray);
tmpl = gEntityManager.allocateTemplate([becsID!CBig].staticArray);
allocDealloc100k();
}
void multiSmallTmplPreAlloc()
{
tmpl = gEM.allocateTemplate([becsID!CShort, becsID!CLong, becsID!CInt, becsID!CUInt].staticArray);
tmpl = gEntityManager.allocateTemplate([becsID!CShort, becsID!CLong, becsID!CInt, becsID!CUInt].staticArray);
allocDealloc100k();
}
void multiBigTmplPreAlloc()
{
tmpl = gEM.allocateTemplate([becsID!CLong, becsID!CInt, becsID!CUInt, becsID!CBig].staticArray);
tmpl = gEntityManager.allocateTemplate([becsID!CLong, becsID!CInt, becsID!CUInt, becsID!CBig].staticArray);
allocDealloc100k();
}
@("AddEntities100k1comp2bPreAlloc") @(before, &smallTmplPreAlloc)
unittest
{
foreach(i; 0..100_000)gEM.addEntity(tmpl);
foreach(i; 0..100_000)gEntityManager.addEntity(tmpl);
}
@("AddEntities100k1comp128bPreAlloc") @(before, &bigTmplPreAlloc)
unittest
{
foreach(i; 0..100_000)gEM.addEntity(tmpl);
foreach(i; 0..100_000)gEntityManager.addEntity(tmpl);
}
@("AddEntities100k4comp18bPreAlloc") @(before, &multiSmallTmplPreAlloc)
unittest
{
foreach(i; 0..100_000)gEM.addEntity(tmpl);
foreach(i; 0..100_000)gEntityManager.addEntity(tmpl);
}
@("AddEntities100k4comp144bPreAlloc") @(before, &multiBigTmplPreAlloc)
unittest
{
foreach(i; 0..100_000)gEM.addEntity(tmpl);
foreach(i; 0..100_000)gEntityManager.addEntity(tmpl);
}