Hi! I'm making my way into DOTS and I'm trying to understand how DOTS works.
So I've made this code with some stupid overhead for debugging:
public partial struct RotatingCubeSystem : ISystem
{
public void OnCreate(ref SystemState state)
{
state.RequireForUpdate<RotatingCube>();
}
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
var job = new RotatingCubeJob
{
deltaTime = SystemAPI.Time.DeltaTime,
};
job.ScheduleParallel();
}
public partial struct RotatingCubeJob : IJobEntity
{
public float deltaTime;
[BurstCompile]
public void Execute(ref LocalTransform localTransform, in RotatingCube rotatingCube)
{
var power = 1;
for (var i = 0; i < 100000; i++)
{
power *= 2000;
power /= 2000;
}
localTransform = localTransform.RotateY(rotatingCube.rotationSpeed * deltaTime * power);
}
}
}
However, when I was running the content of Execute from my job inside the OnUpdate I was having roughly 0.007ms of execution time against between 1.5ms and 5ms (per worker) now using jobs.
I'm trying to understand why this is happening. Shouldn't I be having similar results or even "faster" running multithreaded?