mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-25 09:30:03 +00:00
add relationship benchmark
This commit is contained in:
parent
b6b1f77917
commit
1651de4f29
1 changed files with 36 additions and 0 deletions
|
@ -61,6 +61,42 @@ do TITLE "set"
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- we have a separate benchmark for relationships.
|
||||||
|
-- this is due to that relationships have a very high id compared to normal
|
||||||
|
-- components, which cause them to get added into the hashmap portion.
|
||||||
|
do TITLE "set relationship"
|
||||||
|
|
||||||
|
local world = jecs.World.new()
|
||||||
|
local A = world:entity()
|
||||||
|
|
||||||
|
local entities = table.create(N)
|
||||||
|
|
||||||
|
for i = 1, N do
|
||||||
|
entities[i] = world:entity()
|
||||||
|
world:set(entities[i], A, 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
local pair = jecs.pair(A, world:entity())
|
||||||
|
|
||||||
|
BENCH("add", function()
|
||||||
|
for i = 1, START(N) do
|
||||||
|
world:set(entities[i], pair, 1)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
BENCH("set", function()
|
||||||
|
for i = 1, START(N) do
|
||||||
|
world:set(entities[i], pair, 2)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
BENCH("remove", function()
|
||||||
|
for i = 1, START(N) do
|
||||||
|
world:remove(entities[i], pair)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
do TITLE "get"
|
do TITLE "get"
|
||||||
|
|
||||||
local world = jecs.World.new()
|
local world = jecs.World.new()
|
||||||
|
|
Loading…
Reference in a new issue