I’ve encountered similar situations and I’d love to be wrong but as far as I’m aware, the answer is No.
My solution is to break up the internal of large jobs and bench them separate (it’s still 1 job.)
Let me give a quick example as it makes much more sense.
public void Execute(Entity entity, int team, float3 position, float radius, float2 forward, float fieldOfView)
{
// ...
var computer = new VisibilityPolygonComputer(positionScaled, radiusScaled);
var hits = this.GetHits(position, radius);
// Add occluder from hits
for (var i = 0; i < hits.Length; i++)
{
// ..
visibility.AddCircleOccluder(localCenter, localRadius, body);
}
// ..
var observedObstructions = new NativeHashMap<Entity, RigidBody>(hits.Length, Allocator.Temp);
computer.Compute(polygon, observedObstructions);
var visit = this.GetCircleMapper(controllerEntity, position.xz, radius, observerHistory);
var line = new LineDrawing<CircleMapper>(visit);
var draw = new RasterizeTriangles<LineDrawingCircleMapperT>>(line);
// ..
for (var i = 0; i < observedObstructions.Length; i++)
{
// ..
draw.Draw(localPosition, p1, p2);
}
}
This is just a very basic snippet of a part of a very large job (compiles to something like 40k lines of assembly) but I breakup the logic into separate structs base on a specific task.
public struct VisibilityPolygonComputer : IDisposable
public struct CircleMapper : IMapper
public struct LineDrawing<T> : ILine
where T : struct, IMapper
public struct RasterizeTriangles<T>
where T : struct, ILine
I then use Unity’s performance testing package to test the performance of each thing separately, both with and without burst.
-edit-
for example here is a simple job for my compute performance test
[BurstCompile]
private struct ComputeJob : IJob
{
public VisibilityPolygonComputer Computer;
public void Execute()
{
this.Computer.Compute(new NativeList<float2>(Allocator.Temp), new NativeHashMap<Entity, RigidBody>(128, Allocator.Temp));
}
}
[TestCase(10, 1)]
[TestCase(100, 1)]
[TestCase(10, 100)]
[TestCase(100, 100)]
[TestCase(10, 1000)]
[TestCase(100, 1000)]
[Performance]
public void ComputeTestBurst(int count, int instances)
{
VisibilityPolygonComputer[] computer = new VisibilityPolygonComputer[instances];
NativeArray<JobHandle> handles = new NativeArray<JobHandle>(instances, Allocator.Temp);
Measure.Method(() =>
{
for (var i = 0; i < instances; i++)
{
handles[i] = new ComputeJob { Computer = computer[i] }.Schedule();
}
JobHandle.CompleteAll(handles);
})
.SetUp(() =>
{
// setup
// ..
})
.CleanUp(() =>
{
// cleanup
// ..
})
.Run();
handles.Dispose();
}
Giving me a nice little little performance report of a single method used within a job.