jecs/benches/visual/query.bench.luau

116 lines
2.1 KiB
Text
Raw Normal View History

2024-04-23 15:10:49 +00:00
--!optimize 2
--!native
local ReplicatedStorage = game:GetService("ReplicatedStorage")
2024-04-24 15:32:07 +00:00
2025-06-25 11:31:25 +00:00
local jecs = require(ReplicatedStorage.Lib:Clone())
2025-10-21 22:36:00 +00:00
local chrono = require(ReplicatedStorage.chronoecs:Clone())
2025-06-25 11:31:25 +00:00
local ecs = jecs.world()
2025-10-21 22:36:00 +00:00
local ccs = chrono.new()
2024-04-23 15:10:49 +00:00
2024-04-30 23:09:15 +00:00
local D1 = ecs:component()
local D2 = ecs:component()
local D3 = ecs:component()
local D4 = ecs:component()
local D5 = ecs:component()
local D6 = ecs:component()
local D7 = ecs:component()
local D8 = ecs:component()
2024-04-24 15:32:07 +00:00
2025-10-21 22:36:00 +00:00
local E1 = ccs:component()
local E2 = ccs:component()
local E3 = ccs:component()
local E4 = ccs:component()
local E5 = ccs:component()
local E6 = ccs:component()
local E7 = ccs:component()
local E8 = ccs:component()
local d_components = {}
local e_components = {}
for i = 1, 150 do
ecs:component()
ccs:component()
end
2024-04-25 05:26:38 +00:00
2024-07-15 18:29:06 +00:00
local function flip()
2025-10-21 22:36:00 +00:00
return math.random() >= 0.5
2024-04-23 15:10:49 +00:00
end
local N = 2 ^ 16 - 2
2024-04-25 14:26:30 +00:00
2024-07-15 18:29:06 +00:00
for i = 1, N do
2024-04-23 15:10:49 +00:00
local entity = ecs:entity()
2025-10-21 22:36:00 +00:00
local m = ccs:entity()
2024-04-23 15:10:49 +00:00
2024-07-15 18:29:06 +00:00
if flip() then
2025-08-31 01:38:06 +00:00
ecs:set(entity, D1, true)
2025-10-21 22:36:00 +00:00
ccs:add(m, E1)
ccs:set(m, E1, true)
2024-04-23 15:10:49 +00:00
end
2024-07-15 18:29:06 +00:00
if flip() then
2025-08-31 01:38:06 +00:00
ecs:set(entity, D2, true)
2025-10-21 22:36:00 +00:00
ccs:add(m, E2)
ccs:set(m, E2, true)
2024-04-23 15:10:49 +00:00
end
2024-07-15 18:29:06 +00:00
if flip() then
2025-08-31 01:38:06 +00:00
ecs:set(entity, D3, true)
2025-10-21 22:36:00 +00:00
ccs:add(m, E3)
ccs:set(m, E3, true)
2024-04-23 15:10:49 +00:00
end
2024-07-15 18:29:06 +00:00
if flip() then
2025-08-31 01:38:06 +00:00
ecs:set(entity, D4, true)
2025-10-21 22:36:00 +00:00
ccs:add(m, E4)
ccs:set(m, E4, true)
2024-04-23 15:10:49 +00:00
end
2024-07-15 18:29:06 +00:00
if flip() then
2025-08-31 01:38:06 +00:00
ecs:set(entity, D5, true)
2025-10-21 22:36:00 +00:00
ccs:add(m, E4)
ccs:set(m, E5, true)
2024-04-23 15:10:49 +00:00
end
2024-07-15 18:29:06 +00:00
if flip() then
2025-08-31 01:38:06 +00:00
ecs:set(entity, D6, true)
2025-10-21 22:36:00 +00:00
ccs:add(m, E6)
ccs:set(m, E6, true)
2024-04-23 15:10:49 +00:00
end
2024-07-15 18:29:06 +00:00
if flip() then
2025-08-31 01:38:06 +00:00
ecs:set(entity, D7, true)
2025-10-21 22:36:00 +00:00
ccs:add(m, E7)
ccs:set(m, E7, true)
2024-04-23 15:10:49 +00:00
end
2025-08-31 01:38:06 +00:00
if flip() then
2025-10-21 22:36:00 +00:00
ccs:add(m, E8)
2025-08-31 01:38:06 +00:00
ecs:set(entity, D8, true)
2025-10-21 22:36:00 +00:00
ccs:set(m, E8, true)
2024-04-25 14:26:30 +00:00
end
2024-04-23 15:10:49 +00:00
end
return {
ParameterGenerator = function()
return
2024-07-15 18:29:06 +00:00
end,
2024-04-23 15:10:49 +00:00
Functions = {
2025-06-25 11:31:25 +00:00
-- Matter = function()
-- for entityId, firstComponent in newWorld:query(A2, A4, A6, A8) do
-- end
-- end,
-- ECR = function()
-- for entityId, firstComponent in registry2:view(B2, B4, B6, B8) do
-- end
-- end,
--
2025-10-21 22:36:00 +00:00
chrono = function()
for entityId, firstComponent in ccs:view(E2, E4, E6, E8) do
end
end,
2024-09-26 13:40:50 +00:00
2024-07-15 18:29:06 +00:00
Jecs = function()
2025-10-21 22:36:00 +00:00
for entityId, firstComponent in ecs:query(D2, D4, D6, D8) do
end
2024-04-25 14:26:30 +00:00
end,
2024-04-23 15:10:49 +00:00
},
}