Skip to content

Commit 189269f

Browse files
committed
aos variant of spawn/clone functions WIP
1 parent e89b91f commit 189269f

4 files changed

Lines changed: 920 additions & 7 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ execute :: query -> {execute_state? -> chunk?, entity[]?, integer?}, execute_sta
9595
9696
process :: system... -> ()
9797
98+
spawn :: <fragment, component>? -> entity
99+
clone :: entity -> <fragment, component>? -> entity
100+
98101
spawn_at :: chunk?, fragment[]?, component[]? -> entity
99102
spawn_as :: entity?, fragment[]?, component[]? -> entity
100103
spawn_with :: fragment[]?, component[]? -> entity

develop/unbench.lua

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,171 @@ basics.describe_bench(string.format('create and destroy %d entities with 5 compo
528528

529529
print '----------------------------------------'
530530

531+
basics.describe_bench(string.format('create and destroy %d entities with 1 components / spawn', N),
532+
---@param entities evolved.id[]
533+
function(entities)
534+
local spawn = evo.spawn
535+
536+
local components = { [F1] = true }
537+
538+
for i = 1, N do
539+
entities[i] = spawn(components)
540+
end
541+
542+
evo.batch_destroy(Q1)
543+
end, function()
544+
return {}
545+
end)
546+
547+
basics.describe_bench(string.format('create and destroy %d entities with 2 components / spawn', N),
548+
---@param entities evolved.id[]
549+
function(entities)
550+
local spawn = evo.spawn
551+
552+
local components = { [F1] = true, [F2] = true }
553+
554+
for i = 1, N do
555+
entities[i] = spawn(components)
556+
end
557+
558+
evo.batch_destroy(Q1)
559+
end, function()
560+
return {}
561+
end)
562+
563+
basics.describe_bench(string.format('create and destroy %d entities with 3 components / spawn', N),
564+
---@param entities evolved.id[]
565+
function(entities)
566+
local spawn = evo.spawn
567+
568+
local components = { [F1] = true, [F2] = true, [F3] = true }
569+
570+
for i = 1, N do
571+
entities[i] = spawn(components)
572+
end
573+
574+
evo.batch_destroy(Q1)
575+
end, function()
576+
return {}
577+
end)
578+
579+
basics.describe_bench(string.format('create and destroy %d entities with 4 components / spawn', N),
580+
---@param entities evolved.id[]
581+
function(entities)
582+
local spawn = evo.spawn
583+
584+
local components = { [F1] = true, [F2] = true, [F3] = true, [F4] = true }
585+
586+
for i = 1, N do
587+
entities[i] = spawn(components)
588+
end
589+
590+
evo.batch_destroy(Q1)
591+
end, function()
592+
return {}
593+
end)
594+
595+
basics.describe_bench(string.format('create and destroy %d entities with 5 components / spawn', N),
596+
---@param entities evolved.id[]
597+
function(entities)
598+
local spawn = evo.spawn
599+
600+
local components = { [F1] = true, [F2] = true, [F3] = true, [F4] = true, [F5] = true }
601+
602+
for i = 1, N do
603+
entities[i] = spawn(components)
604+
end
605+
606+
evo.batch_destroy(Q1)
607+
end, function()
608+
return {}
609+
end)
610+
611+
print '----------------------------------------'
612+
613+
614+
basics.describe_bench(string.format('create and destroy %d entities with 1 components / clone', N),
615+
---@param entities evolved.id[]
616+
function(entities)
617+
local clone = evo.clone
618+
619+
local prefab = evo.spawn({ [F1] = true })
620+
621+
for i = 1, N do
622+
entities[i] = clone(prefab)
623+
end
624+
625+
evo.batch_destroy(Q1)
626+
end, function()
627+
return {}
628+
end)
629+
630+
basics.describe_bench(string.format('create and destroy %d entities with 2 components / clone', N),
631+
---@param entities evolved.id[]
632+
function(entities)
633+
local clone = evo.clone
634+
635+
local prefab = evo.spawn({ [F1] = true, [F2] = true })
636+
637+
for i = 1, N do
638+
entities[i] = clone(prefab)
639+
end
640+
641+
evo.batch_destroy(Q1)
642+
end, function()
643+
return {}
644+
end)
645+
646+
basics.describe_bench(string.format('create and destroy %d entities with 3 components / clone', N),
647+
---@param entities evolved.id[]
648+
function(entities)
649+
local clone = evo.clone
650+
651+
local prefab = evo.spawn({ [F1] = true, [F2] = true, [F3] = true })
652+
653+
for i = 1, N do
654+
entities[i] = clone(prefab)
655+
end
656+
657+
evo.batch_destroy(Q1)
658+
end, function()
659+
return {}
660+
end)
661+
662+
basics.describe_bench(string.format('create and destroy %d entities with 4 components / clone', N),
663+
---@param entities evolved.id[]
664+
function(entities)
665+
local clone = evo.clone
666+
667+
local prefab = evo.spawn({ [F1] = true, [F2] = true, [F3] = true, [F4] = true })
668+
669+
for i = 1, N do
670+
entities[i] = clone(prefab)
671+
end
672+
673+
evo.batch_destroy(Q1)
674+
end, function()
675+
return {}
676+
end)
677+
678+
basics.describe_bench(string.format('create and destroy %d entities with 5 components / clone', N),
679+
---@param entities evolved.id[]
680+
function(entities)
681+
local clone = evo.clone
682+
683+
local prefab = evo.spawn({ [F1] = true, [F2] = true, [F3] = true, [F4] = true, [F5] = true })
684+
685+
for i = 1, N do
686+
entities[i] = clone(prefab)
687+
end
688+
689+
evo.batch_destroy(Q1)
690+
end, function()
691+
return {}
692+
end)
693+
694+
print '----------------------------------------'
695+
531696
basics.describe_bench(string.format('create and destroy %d entities with 1 components / spawn_at', N),
532697
---@param entities evolved.id[]
533698
function(entities)

0 commit comments

Comments
 (0)