mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-25 09:30:03 +00:00
Remove matter from main
This commit is contained in:
parent
93165e0ad9
commit
c768cf3655
3 changed files with 1 additions and 3260 deletions
|
@ -10,9 +10,6 @@ end
|
||||||
|
|
||||||
local jecs = require("../mirror/init")
|
local jecs = require("../mirror/init")
|
||||||
|
|
||||||
local oldMatter = require("../oldMatter")
|
|
||||||
|
|
||||||
local newMatter = require("../newMatter")
|
|
||||||
type i53 = number
|
type i53 = number
|
||||||
|
|
||||||
do
|
do
|
||||||
|
@ -106,194 +103,4 @@ do
|
||||||
|
|
||||||
view_bench(ecs, D1, D2, D3, D4, D5, D6, D7, D8)
|
view_bench(ecs, D1, D2, D3, D4, D5, D6, D7, D8)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
|
||||||
TITLE(testkit.color.white_underline("OldMatter query"))
|
|
||||||
|
|
||||||
local ecs = oldMatter.World.new()
|
|
||||||
local component = oldMatter.component
|
|
||||||
|
|
||||||
do
|
|
||||||
TITLE("one component in common")
|
|
||||||
local function view_bench(world: jecs.World, A: i53, B: i53, C: i53, D: i53, E: i53, F: i53, G: i53, H: i53)
|
|
||||||
BENCH("1 component", function()
|
|
||||||
for _ in world:query(A) do
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
BENCH("2 component", function()
|
|
||||||
for _ in world:query(A, B) do
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
BENCH("4 component", function()
|
|
||||||
for _ in world:query(A, B, C, D) do
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
BENCH("8 component", function()
|
|
||||||
for _ in world:query(A, B, C, D, E, F, G, H) do
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
local D1 = component()
|
|
||||||
local D2 = component()
|
|
||||||
local D3 = component()
|
|
||||||
local D4 = component()
|
|
||||||
local D5 = component()
|
|
||||||
local D6 = component()
|
|
||||||
local D7 = component()
|
|
||||||
local D8 = component()
|
|
||||||
|
|
||||||
local function flip()
|
|
||||||
return math.random() >= 0.15
|
|
||||||
end
|
|
||||||
|
|
||||||
local added = 0
|
|
||||||
local archetypes = {}
|
|
||||||
for i = 1, 2 ^ 16 - 2 do
|
|
||||||
local entity = ecs:spawn()
|
|
||||||
|
|
||||||
local combination = ""
|
|
||||||
|
|
||||||
if flip() then
|
|
||||||
combination ..= "B"
|
|
||||||
ecs:insert(entity, D2({value = true}))
|
|
||||||
end
|
|
||||||
if flip() then
|
|
||||||
combination ..= "C"
|
|
||||||
ecs:insert(entity, D3({value = true}))
|
|
||||||
end
|
|
||||||
if flip() then
|
|
||||||
combination ..= "D"
|
|
||||||
ecs:insert(entity, D4({value = true}))
|
|
||||||
end
|
|
||||||
if flip() then
|
|
||||||
combination ..= "E"
|
|
||||||
ecs:insert(entity, D5({value = true}))
|
|
||||||
end
|
|
||||||
if flip() then
|
|
||||||
combination ..= "F"
|
|
||||||
ecs:insert(entity, D6({value = true}))
|
|
||||||
end
|
|
||||||
if flip() then
|
|
||||||
combination ..= "G"
|
|
||||||
ecs:insert(entity, D7({value = true}))
|
|
||||||
end
|
|
||||||
if flip() then
|
|
||||||
combination ..= "H"
|
|
||||||
ecs:insert(entity, D8({value = true}))
|
|
||||||
end
|
|
||||||
|
|
||||||
if #combination == 7 then
|
|
||||||
added += 1
|
|
||||||
ecs:insert(entity, D1({value = true}))
|
|
||||||
end
|
|
||||||
archetypes[combination] = true
|
|
||||||
end
|
|
||||||
|
|
||||||
local a = 0
|
|
||||||
for _ in archetypes do
|
|
||||||
a += 1
|
|
||||||
end
|
|
||||||
|
|
||||||
view_bench(ecs, D1, D2, D3, D4, D5, D6, D7, D8)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
do
|
|
||||||
TITLE(testkit.color.white_underline("NewMatter query"))
|
|
||||||
|
|
||||||
local ecs = newMatter.World.new()
|
|
||||||
local component = newMatter.component
|
|
||||||
|
|
||||||
do
|
|
||||||
TITLE("one component in common")
|
|
||||||
local function view_bench(world: jecs.World, A: i53, B: i53, C: i53, D: i53, E: i53, F: i53, G: i53, H: i53)
|
|
||||||
BENCH("1 component", function()
|
|
||||||
for _ in world:query(A) do
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
BENCH("2 component", function()
|
|
||||||
for _ in world:query(A, B) do
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
BENCH("4 component", function()
|
|
||||||
for _ in world:query(A, B, C, D) do
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
BENCH("8 component", function()
|
|
||||||
for _ in world:query(A, B, C, D, E, F, G, H) do
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
local D1 = component()
|
|
||||||
local D2 = component()
|
|
||||||
local D3 = component()
|
|
||||||
local D4 = component()
|
|
||||||
local D5 = component()
|
|
||||||
local D6 = component()
|
|
||||||
local D7 = component()
|
|
||||||
local D8 = component()
|
|
||||||
|
|
||||||
local function flip()
|
|
||||||
return math.random() >= 0.15
|
|
||||||
end
|
|
||||||
|
|
||||||
local added = 0
|
|
||||||
local archetypes = {}
|
|
||||||
for i = 1, 2 ^ 16 - 2 do
|
|
||||||
local entity = ecs:spawn()
|
|
||||||
|
|
||||||
local combination = ""
|
|
||||||
|
|
||||||
if flip() then
|
|
||||||
combination ..= "B"
|
|
||||||
ecs:insert(entity, D2({value = true}))
|
|
||||||
end
|
|
||||||
if flip() then
|
|
||||||
combination ..= "C"
|
|
||||||
ecs:insert(entity, D3({value = true}))
|
|
||||||
end
|
|
||||||
if flip() then
|
|
||||||
combination ..= "D"
|
|
||||||
ecs:insert(entity, D4({value = true}))
|
|
||||||
end
|
|
||||||
if flip() then
|
|
||||||
combination ..= "E"
|
|
||||||
ecs:insert(entity, D5({value = true}))
|
|
||||||
end
|
|
||||||
if flip() then
|
|
||||||
combination ..= "F"
|
|
||||||
ecs:insert(entity, D6({value = true}))
|
|
||||||
end
|
|
||||||
if flip() then
|
|
||||||
combination ..= "G"
|
|
||||||
ecs:insert(entity, D7({value = true}))
|
|
||||||
end
|
|
||||||
if flip() then
|
|
||||||
combination ..= "H"
|
|
||||||
ecs:insert(entity, D8({value = true}))
|
|
||||||
end
|
|
||||||
|
|
||||||
if #combination == 7 then
|
|
||||||
added += 1
|
|
||||||
ecs:insert(entity, D1({value = true}))
|
|
||||||
end
|
|
||||||
archetypes[combination] = true
|
|
||||||
end
|
|
||||||
|
|
||||||
local a = 0
|
|
||||||
for _ in archetypes do
|
|
||||||
a += 1
|
|
||||||
end
|
|
||||||
|
|
||||||
view_bench(ecs, D1, D2, D3, D4, D5, D6, D7, D8)
|
|
||||||
end
|
|
||||||
end
|
|
1499
newMatter.lua
1499
newMatter.lua
File diff suppressed because it is too large
Load diff
1567
oldMatter.lua
1567
oldMatter.lua
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue