From 8dcc1dff7b916191bbfc0aabd9af9c4221ceb297 Mon Sep 17 00:00:00 2001 From: Martin Evans Date: Sat, 25 Apr 2026 01:38:56 +0100 Subject: [PATCH] Fixed Morpeh entity creation - Create3 benchmark created entity with 2 components - Create2 benchmark created entity with 3 components - Both benchmarks actually created N separate entities, instead of one entity with N components --- .../CreateEntityWithThreeComponents/Morpeh.cs | 8 ++++++-- .../CreateEntityWithTwoComponents/Morpeh.cs | 8 +++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/source/Ecs.CSharp.Benchmark/CreateEntityWithThreeComponents/Morpeh.cs b/source/Ecs.CSharp.Benchmark/CreateEntityWithThreeComponents/Morpeh.cs index 71ca182..fe174a3 100644 --- a/source/Ecs.CSharp.Benchmark/CreateEntityWithThreeComponents/Morpeh.cs +++ b/source/Ecs.CSharp.Benchmark/CreateEntityWithThreeComponents/Morpeh.cs @@ -16,8 +16,10 @@ public void Morpeh_Direct() World world = _context.World; for (int i = 0; i < EntityCount; ++i) { - world.CreateEntity().AddComponent(); - world.CreateEntity().AddComponent(); + var entity = world.CreateEntity(); + entity.AddComponent(); + entity.AddComponent(); + entity.AddComponent(); } world.Commit(); @@ -30,11 +32,13 @@ public void Morpeh_Stash() World world = _context.World; Stash stash1 = world.GetStash(); Stash stash2 = world.GetStash(); + Stash stash3 = world.GetStash(); for (int i = 0; i < EntityCount; ++i) { Entity entity = world.CreateEntity(); stash1.Add(entity); stash2.Add(entity); + stash3.Add(entity); } world.Commit(); diff --git a/source/Ecs.CSharp.Benchmark/CreateEntityWithTwoComponents/Morpeh.cs b/source/Ecs.CSharp.Benchmark/CreateEntityWithTwoComponents/Morpeh.cs index 7ec1e93..e0660ef 100644 --- a/source/Ecs.CSharp.Benchmark/CreateEntityWithTwoComponents/Morpeh.cs +++ b/source/Ecs.CSharp.Benchmark/CreateEntityWithTwoComponents/Morpeh.cs @@ -16,9 +16,9 @@ public void Morpeh_Direct() World world = _context.World; for (int i = 0; i < EntityCount; ++i) { - world.CreateEntity().AddComponent(); - world.CreateEntity().AddComponent(); - world.CreateEntity().AddComponent(); + var entity = world.CreateEntity(); + entity.AddComponent(); + entity.AddComponent(); } world.Commit(); @@ -31,13 +31,11 @@ public void Morpeh_Stash() World world = _context.World; Stash stash1 = world.GetStash(); Stash stash2 = world.GetStash(); - Stash stash3 = world.GetStash(); for (int i = 0; i < EntityCount; ++i) { Entity entity = world.CreateEntity(); stash1.Add(entity); stash2.Add(entity); - stash3.Add(entity); } world.Commit();