mirror of
https://github.com/BlackMATov/evolved.lua.git
synced 2025-12-15 04:15:28 +07:00
add tiny-ecs cache/nocache bench variants
This commit is contained in:
@@ -131,7 +131,7 @@ end)
|
||||
---@param b evolved.entity
|
||||
---@param A evolved.query
|
||||
---@param B evolved.query
|
||||
common.describe('Entity Cycle Simple', function(a, b, A, B)
|
||||
common.describe('Entity Cycle (Simple)', function(a, b, A, B)
|
||||
---@type any[]
|
||||
local to_create = {}
|
||||
|
||||
@@ -177,7 +177,7 @@ end)
|
||||
---@param b evolved.entity
|
||||
---@param A evolved.query
|
||||
---@param B evolved.query
|
||||
common.describe('Entity Cycle Batched', function(a, b, A, B)
|
||||
common.describe('Entity Cycle (Batched)', function(a, b, A, B)
|
||||
---@type any[]
|
||||
local to_create = {}
|
||||
|
||||
@@ -210,7 +210,7 @@ end)
|
||||
---@param b evolved.entity
|
||||
---@param A evolved.query
|
||||
---@param AB evolved.query
|
||||
common.describe('Add / Remove Simple', function(b, A, AB)
|
||||
common.describe('Add / Remove (Simple)', function(b, A, AB)
|
||||
---@type evolved.entity[]
|
||||
local to_insert = {}
|
||||
|
||||
@@ -255,7 +255,7 @@ end)
|
||||
---@param b evolved.entity
|
||||
---@param A evolved.query
|
||||
---@param AB evolved.query
|
||||
common.describe('Add / Remove Batched', function(b, A, AB)
|
||||
common.describe('Add / Remove (Batched)', function(b, A, AB)
|
||||
assert(10000 == evo.registry.query_insert(A, b))
|
||||
assert(10000 == evo.registry.query_remove(AB, b))
|
||||
end, function()
|
||||
|
||||
@@ -104,7 +104,7 @@ end, function()
|
||||
return w
|
||||
end)
|
||||
|
||||
common.describe('Entity Cycle', function(w)
|
||||
common.describe('Entity Cycle (Cache)', function(w)
|
||||
tiny.update(w, 0.016)
|
||||
end, function()
|
||||
local w = tiny.world()
|
||||
@@ -130,7 +130,35 @@ end, function()
|
||||
return w
|
||||
end)
|
||||
|
||||
common.describe('Add / Remove', function(w)
|
||||
common.describe('Entity Cycle (No Cache)', function(w)
|
||||
tiny.update(w, 0.016)
|
||||
end, function()
|
||||
local w = tiny.world()
|
||||
|
||||
for _ = 1, 1000 do
|
||||
tiny.addEntity(w, { a = 0 })
|
||||
end
|
||||
|
||||
local A = tiny.processingSystem()
|
||||
A.nocache = true
|
||||
A.filter = tiny.requireAll('a')
|
||||
A.process = function(_, e) tiny.addEntity(w, { b = e.a }) end
|
||||
A.postProcess = function(_) tiny.refresh(w) end
|
||||
|
||||
local B = tiny.processingSystem()
|
||||
B.nocache = true
|
||||
B.filter = tiny.requireAll('b')
|
||||
B.process = function(_, e) tiny.removeEntity(w, e) end
|
||||
B.postProcess = function(_) tiny.refresh(w) end
|
||||
|
||||
tiny.addSystem(w, A)
|
||||
tiny.addSystem(w, B)
|
||||
|
||||
tiny.refresh(w)
|
||||
return w
|
||||
end)
|
||||
|
||||
common.describe('Add / Remove (Cache)', function(w)
|
||||
tiny.update(w, 0.016)
|
||||
end, function()
|
||||
local w = tiny.world()
|
||||
@@ -161,3 +189,37 @@ end, function()
|
||||
tiny.refresh(w)
|
||||
return w
|
||||
end)
|
||||
|
||||
common.describe('Add / Remove (No Cache)', function(w)
|
||||
tiny.update(w, 0.016)
|
||||
end, function()
|
||||
local w = tiny.world()
|
||||
|
||||
for _ = 1, 10000 do
|
||||
tiny.addEntity(w, { a = 0 })
|
||||
end
|
||||
|
||||
local A = tiny.processingSystem()
|
||||
A.nocache = true
|
||||
A.filter = tiny.requireAll('a')
|
||||
A.process = function(_, e)
|
||||
e.b = 0
|
||||
tiny.addEntity(w, e)
|
||||
end
|
||||
A.postProcess = function(_) tiny.refresh(w) end
|
||||
|
||||
local AB = tiny.processingSystem()
|
||||
AB.nocache = true
|
||||
AB.filter = tiny.requireAll('a', 'b')
|
||||
AB.process = function(_, e)
|
||||
e.b = nil
|
||||
tiny.addEntity(w, e)
|
||||
end
|
||||
AB.postProcess = function(_) tiny.refresh(w) end
|
||||
|
||||
tiny.addSystem(w, A)
|
||||
tiny.addSystem(w, AB)
|
||||
|
||||
tiny.refresh(w)
|
||||
return w
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user