Skip to content

Commit

Permalink
Tests - add Test_EntityData_access_Perf_Reference()
Browse files Browse the repository at this point in the history
  • Loading branch information
friflo committed Aug 1, 2024
1 parent 02e1c79 commit 05d7230
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Tests/ECS/Entity/Test_EntityData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,25 @@ public static void Test_EntityData_access_Perf()
}
Console.WriteLine($"Test_EntityData_access_Perf count: {count}, duration: {sw.ElapsedMilliseconds} ms");
}

[Test]
public static void Test_EntityData_access_Perf_Reference()
{
int count = 100; // 1_000_000_000
// Test_EntityData_access_Perf_Reference count: 1000000000, duration: 12405 ms
var store = new EntityStore();
var entity = store.CreateEntity(new Position(1,2,3), new EntityName("test"), new Scale3(), new MyComponent1());

var sw = new Stopwatch();
sw.Start();
for (int n = 0; n < count; n++) {
entity.GetComponent<Position>();
entity.GetComponent<EntityName>();
entity.GetComponent<Scale3>();
entity.GetComponent<MyComponent1>();
}
Console.WriteLine($"Test_EntityData_access_Perf_Reference count: {count}, duration: {sw.ElapsedMilliseconds} ms");
}
}

}

0 comments on commit 05d7230

Please sign in to comment.