Show More
Commit Description:
Add timers for Simulation and various engines...
Commit Description:
Add timers for Simulation and various engines Starting to add additional timers for different stages of the process of updating in order to get more insight into what is slowing it down. The update takes 9ms, which is much longer than it used to. Engine-specific timers are coming later.
Show/Diff file:
Action:
encompass-cs/test/GeneralRendererTest.cs
71 lines | 2.0 KiB | text/x-csharp | CSharpLexer
using NUnit.Framework;
using Encompass;
namespace Tests
{
public static class GeneralRendererTest
{
struct AComponent : IComponent { }
public class SingletonRead
{
static (AComponent, Entity) result;
class TestRenderer : GeneralRenderer
{
public override void Render()
{
ref readonly var entity = ref ReadEntity<AComponent>();
result = (GetComponent<AComponent>(entity), entity);
}
}
[Test]
public void SingletonComponent()
{
var worldBuilder = new WorldBuilder();
worldBuilder.AddGeneralRenderer(new TestRenderer(), 1);
AComponent aComponent;
var entity = worldBuilder.CreateEntity();
worldBuilder.SetComponent(entity, aComponent);
var world = worldBuilder.Build();
world.Update(0.01f);
world.Draw();
world.Update(0.01);
world.Draw();
Assert.That(result, Is.EqualTo((aComponent, entity)));
}
[Test]
public void MultipleComponents()
{
var worldBuilder = new WorldBuilder();
worldBuilder.AddGeneralRenderer(new TestRenderer(), 1);
AComponent aComponent;
AComponent aComponentTwo;
var entity = worldBuilder.CreateEntity();
worldBuilder.SetComponent(entity, aComponent);
var entityB = worldBuilder.CreateEntity();
worldBuilder.SetComponent(entityB, aComponentTwo);
var world = worldBuilder.Build();
world.Update(0.01f);
world.Draw();
world.Update(0.01f);
world.Draw();
Assert.That(result, Is.EqualTo((aComponent, entity)).Or.EqualTo((aComponentTwo, entityB)));
}
}
}
}