TimingDataTracker Class

public class TimingDataTracker : MonoBehaviour

Tracks Asset Chunk Timing Data for SAM.

Timing data can only be tracked in the editor or in Development Builds via the this component. To do so, simply add the component to the scene and make sure it is activated, and SAM will take care of the rest. You can then print out timing data by hooking up the LogTimingDataWithSamples or method LogTimingDataWithoutSamples to a button, or by manually calling it. You can also do a custom print that does not using UnityEngine.Debug.Log via the CustomPrintTimingData method, or retrieve the timing data directly for some other purpose (via the GetTimingData method). Any other public method should not be called by you!

All timing data is an average of 1 or more samples, unless timing data is not available because an operation was never carried out for the asset chunk, in which case Samples will be 0.

A lot of the data is for async operations only, and thus does not include loading during Two Frame Initialization. Also note that because most Chunk Streamers do not make use of async unload operations to remove asset chunks, unloading related data is rare (it will be 0 if not available).

In general, LogTimingDataWithSamples and LogTimingDataWithoutSamples are the only methods you should need to use, although the GetTimingData can also be used if you wish. The other public methods should not be called, as they are used exclusively by SAM related members.

Methods

CustomPrintTimingData(int, bool, Action<string>)

public void CustomPrintTimingData(int maxLinesPerMessage, bool includeSampleCounts, Action<string> PrintAction)

Logs the asset chunk timing data stored. Data is logged in a tabbed format, which you can easily copy/paste into a program like Excel for easier viewing and data review. The following information is included for each Asset Chunk that has been loaded by SAM:

1) The ID of the World each Asset Chunk belongs to.

2) The World Grouping Index each Asset Chunk belongs to.

3) The LOD (LOD Group) each Asset Chunk belongs to.

4) The Streamable Grid Cell each Asset Chunk belongs to.

5) The Asset Chunk Index of each chunk (in relation to other asset chunks part of the same World Cell).

6) Initializing Load - Time taken to fire the method used to start an async load operation.

7) Integrating - Time taken to complete an async load operation's final integrate step.

8) Loading - Total time to complete an async load operation, from the moment before initializing it to the moments after integration.

9) Configuring - Time taken to confire the Asset Chunk (for Prefabs, includes instantiation of the asset chunk from its source).

10) Activating - Time taken to activate the Asset Chunk.

11) Deactivating - Time taken to deactivate the Asset Chunk

12) Initializing Unload - Time taken to initialize an async unload operation (uncommon).

13) Deintigrating - Time taken remove the Asset Chunk from main memory during an async unload operation (uncommon).

14) Unloading - Total time to complete an async unload operation, from the memoment before initializng it to the moments after deintigration (uncommon)

15) Destroying - Time per frame used destroying the Asset Chunk or its children. Note, this is not a measure of the time it took each time to destroy the Asset Chunk. It is a measure of the amount of time used in any given frame on Destroy calls on either the asset chunk directly, or its children (if using a Chunk Destroyer). When using a Chunk Destroyer, destruction can occur over multiple frames, so multiple samples can be taken of the same game object asset chunk. In conclusion, this data point can give you a rough idea of the amount of frame time being used on destruction ops, not the time it takes to completely destroy an asset chunk!

16) Releasing - Time taken to release handles associated with the asset chunks (typically only used by the Addressables System).

Parameters

Name Type Description
maxLinesPerMessage int

The maximum number of lines to include in each printed message. A value around 100 is recommended if using UnityEngine.Debug.Log, as longer messages can get cutoff in the editor, however feel free to experiment to find the best value.

includeSampleCounts bool

Whether to include the Sample Counts of the timing data. Sample Counts can give you an indicator of how reliable each piece of data is.

PrintAction Action<string>

The action to use to print the timing data. If you just want UnityEngine.Debug.Log to be used, use LogTimingData instead.


GetTimingData(List<ChunkTimingData>)

public void GetTimingData(List<ChunkTimingData> chunkTimingData)

Gets all chunk timing data, sorted by World ID, then World Grouping Index, LOD, Streamable Grid Cell, and finally chunk index. Put another way, all asset chunk data for one world will be grouped together, then within that group all asset chunks belonging to the same World Groupign are grouped together, then within that group all asset chunks of the same LOD are grouped, and so on.

It is recommended to use the LogTimingDataWithSamples or LogTimingDataWithoutSamples method instead, as this takes care of printing the timing data for you. However, if you want to make use of the data for some other purpose, you can use this method.

Parameters

Name Type Description
chunkTimingData List<ChunkTimingData>

A list that will be filled with the timing data.


LogTimingDataWithSamples(int)

public void LogTimingDataWithSamples(int maxLinesPerMessage)

Logs the asset chunk timing data stored using UnityEngine.Debug.Log with sample counts. Data is logged in a tabbed format, which you can easily copy/paste into a program like Excel for easier viewing and data review. The following information is included for each Asset Chunk that has been loaded by SAM (items 6-16 include an extra column to the right of each item that show the number of samples for that data point):

1) The ID of the World each Asset Chunk belongs to.

2) The World Grouping Index each Asset Chunk belongs to.

3) The LOD (LOD Group) each Asset Chunk belongs to.

4) The Streamable Grid Cell each Asset Chunk belongs to.

5) The Asset Chunk Index of each chunk (in relation to other asset chunks part of the same World Cell).

6) Initializing Load - Time taken to fire the method used to start an async load operation.

7) Integrating - Time taken to complete an async load operation's final integrate step.

8) Loading - Total time to complete an async load operation, from the moment before initializing it to the moments after integration.

9) Configuring - Time taken to confire the Asset Chunk (for Prefabs, includes instantiation of the asset chunk from its source).

10) Activating - Time taken to activate the Asset Chunk.

11) Deactivating - Time taken to deactivate the Asset Chunk

12) Initializing Unload - Time taken to initialize an async unload operation (uncommon).

13) Deintigrating - Time taken remove the Asset Chunk from main memory during an async unload operation (uncommon).

14) Unloading - Total time to complete an async unload operation, from the memoment before initializng it to the moments after deintigration (uncommon)

15) Destroying - Time per frame used destroying the Asset Chunk or its children. Note, this is not a measure of the time it took each time to destroy the Asset Chunk. It is a measure of the amount of time used in any given frame on Destroy calls on either the asset chunk directly, or its children (if using a Chunk Destroyer). When using a Chunk Destroyer, destruction can occur over multiple frames, so multiple samples can be taken of the same game object asset chunk. In conclusion, this data point can give you a rough idea of the amount of frame time being used on destruction ops, not the time it takes to completely destroy an asset chunk!

16) Releasing - Time taken to release handles associated with the asset chunks (typically only used by the Addressables System).

Parameters

Name Type Description
maxLinesPerMessage int

The maximum number of lines to include in each printed message. A value around 100 is recommended if using UnityEngine.Debug.Log, as longer messages can get cutoff in the editor, however feel free to experiment to find the best value.


LogTimingDataWithoutSamples(int)

public void LogTimingDataWithoutSamples(int maxLinesPerMessage)

Logs the asset chunk timing data stored using UnityEngine.Debug.Log without sample counts. Data is logged in a tabbed format, which you can easily copy/paste into a program like Excel for easier viewing and data review. The following information is included for each Asset Chunk that has been loaded by SAM:

1) The ID of the World each Asset Chunk belongs to.

2) The World Grouping Index each Asset Chunk belongs to.

3) The LOD (LOD Group) each Asset Chunk belongs to.

4) The Streamable Grid Cell each Asset Chunk belongs to.

5) The Asset Chunk Index of each chunk (in relation to other asset chunks part of the same World Cell).

6) Initializing Load - Time taken to fire the method used to start an async load operation.

7) Integrating - Time taken to complete an async load operation's final integrate step.

8) Loading - Total time to complete an async load operation, from the moment before initializing it to the moments after integration.

9) Configuring - Time taken to confire the Asset Chunk (for Prefabs, includes instantiation of the asset chunk from its source).

10) Activating - Time taken to activate the Asset Chunk.

11) Deactivating - Time taken to deactivate the Asset Chunk

12) Initializing Unload - Time taken to initialize an async unload operation (uncommon).

13) Deintigrating - Time taken remove the Asset Chunk from main memory during an async unload operation (uncommon).

14) Unloading - Total time to complete an async unload operation, from the memoment before initializng it to the moments after deintigration (uncommon)

15) Destroying - Time per frame used destroying the Asset Chunk or its children. Note, this is not a measure of the time it took each time to destroy the Asset Chunk. It is a measure of the amount of time used in any given frame on Destroy calls on either the asset chunk directly, or its children (if using a Chunk Destroyer). When using a Chunk Destroyer, destruction can occur over multiple frames, so multiple samples can be taken of the same game object asset chunk. In conclusion, this data point can give you a rough idea of the amount of frame time being used on destruction ops, not the time it takes to completely destroy an asset chunk!

16) Releasing - Time taken to release handles associated with the asset chunks (typically only used by the Addressables System).

Parameters

Name Type Description
maxLinesPerMessage int

The maximum number of lines to include in each printed message. A value around 100 is recommended if using UnityEngine.Debug.Log, as longer messages can get cutoff in the editor, however feel free to experiment to find the best value.