Identifying Screen Creation Performance Issues
Introduction
If you have a screen which seems to take a long time to load then this can be the cause of either long load times in generated code or a slow CustomInitialize function. The first step in fixing the problem is to identify whether it is custom or generated code.
Measuring time in CustomInitialize
CustomInitialize can be measured easily by using the TimeManager's SystemCurrentTime property along with the Debugger's CommandLineWrite function. For this example, let's assume a simple CustomInitialize which looks like this:
The actual contents of CustomInitialize don't really matter - this is just some sample code that we can use to show how to measure CustomInitialize time. To measure and output the time, we'll need to do 3 things:
Record the current time at the start of the function
Record the current time at the end of the function
Print out how long the initialize took by subtracting the beginning time from the end time
CustomInitialize can be modified to do this as follows:
Measuring all Initialization including generated code
The example above tells us how long CustomInitialize takes, but it doesn't tell us how long generated code took to execute. This is important if your CustomInitialize code is fast (like less than 1 second) but the Screen still takes a long time to load. We can ask Glue to give us more detailed information to solve this. The steps to solve this are:
Turning on detailed performance logging in Glue
Modifying your code to output load times
Turning on detailed performance logging in Glue
To do this:
Switch to glue
Select "Settings"->"Performance Settings"
Set "RecordInitializeSegments" to "True"
Click "Done"
Now Glue will generate code to measure Screen initialization time. Next we'll output this information on-screen.
Modifying your code to output load times
To do this:
Switch to Visual Studio
Open your Screen that you want to measure the initialization times on
Go to CustomActivity (not CustomInitialize)
Add the following code in CustomActivity:
Where is the slowdown?
So far we've discussed how to measure where slowdowns are occurring.
If the slowdown is in CustomLoadStaticContent or LoadStaticContent (notice the name of your screen will be prefixed), then you can solve the problem either by loading less content or by using a loading screen. For more information on using loading screens, see this page.
Last updated