Last active
May 11, 2020 21:21
-
-
Save jeffvella/9420be274fc90945554b6b0cff4a5d8c to your computer and use it in GitHub Desktop.
How to add burst job timing to the profiler.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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