Skip to content

Instantly share code, notes, and snippets.

@jeffvella
Last active May 11, 2020 21:21
Show Gist options
  • Save jeffvella/9420be274fc90945554b6b0cff4a5d8c to your computer and use it in GitHub Desktop.
Save jeffvella/9420be274fc90945554b6b0cff4a5d8c to your computer and use it in GitHub Desktop.
How to add burst job timing to the profiler.
public unsafe class JobTestSystem : JobComponentSystem
{
private ProfilerMarker _marker;
protected override void OnCreateManager()
{
_marker = new ProfilerMarker("Job1z");
}
protected override JobHandle OnUpdate(JobHandle inputDeps)
{
new Job
{
Marker = _marker,
}.Run();
Debug.Log($"Marker {_marker} Ptr={(long)UnsafeUtility.AddressOf(ref _marker):X}");
return inputDeps;
}
[BurstCompile]
public struct Job : IJob
{
public int TypeIndex;
public void Execute()
{
Marker.Begin();
unchecked
{
for (int i = 0; i < 1000000; i++)
{
TypeIndex += i * (int)Math.Sqrt(i+1);
}
}
Marker.End();
}
public ProfilerMarker Marker;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment