Splitting this out from my "not really sure which thread this goes in" post last night. Performance will likely be something that is off-and-on, not tied to any particular milestone, but rather an accumulation of slowness. It's also an area where sharing techniques could be beneficial.
Lately, I've been focusing on improving responsiveness, with two main goals, the Game scene load, and the Disband Confirmation popup (which I'm using as representative of all popups). The main tool in my toolbox is the C# Stopwatch:
This has allowed me to see what part of the load time is slow, and thus use Amdahl's Law to target areas for improvement. I've also been using the _EnterTree() method in Godot as the start point:
The above gives an estimate of the overall load time (although it doesn't capture time before the node enters the tree; is that significant?), and by moving the stopwatch start/end, or using additional stopwatches, we can figure out which areas are slow.
Using this methodology, I've made a couple targeted improvements:
- Optimizing the PCXToGodot.cs file so that when creating an Image/ImageTexture from a PCX, it only converts the cropped size of the image (when cropping is used), instead of the whole PCX. In some cases such as popup border graphics, this results in 98% fewer pixels being converted, with a corresponding increase in speed.
- Caching ImageTexture and PCX conversion, so we don't have to do them more than once. This can result in the second display of a pop-up taking almost 80% less time than the initial time, and also results in savings when graphics such as leaderheads are used in multiple places.
Combined, this has taken the time to load the disband popup down by more than 80% on first load, and 96% on subsequent loads, from 225 ms on every load to 38 ms (first load), and 8 ms (subsequent loads).
These improvements should be broadly applicable to PCX loads as well, particularly ones that use cropping.
Next I plan to look at implementing some similar improvements for FLC loading.
Lately, I've been focusing on improving responsiveness, with two main goals, the Game scene load, and the Disband Confirmation popup (which I'm using as representative of all popups). The main tool in my toolbox is the C# Stopwatch:
Code:
Stopwatch loadTimer = new Stopwatch();
loadTimer.Start();
//Do some things and stuff
loadTimer.Stop();
TimeSpan stopwatchElapsed = loadTimer.Elapsed;
GD.Print("Game scene load time: " + Convert.ToInt32(stopwatchElapsed.TotalMilliseconds) + " ms");
This has allowed me to see what part of the load time is slow, and thus use Amdahl's Law to target areas for improvement. I've also been using the _EnterTree() method in Godot as the start point:
Code:
public override void _EnterTree()
{
loadTimer.Start();
}
public override void _Ready()
{
//do things
//stop timer, record load time
}
The above gives an estimate of the overall load time (although it doesn't capture time before the node enters the tree; is that significant?), and by moving the stopwatch start/end, or using additional stopwatches, we can figure out which areas are slow.
Using this methodology, I've made a couple targeted improvements:
- Optimizing the PCXToGodot.cs file so that when creating an Image/ImageTexture from a PCX, it only converts the cropped size of the image (when cropping is used), instead of the whole PCX. In some cases such as popup border graphics, this results in 98% fewer pixels being converted, with a corresponding increase in speed.
- Caching ImageTexture and PCX conversion, so we don't have to do them more than once. This can result in the second display of a pop-up taking almost 80% less time than the initial time, and also results in savings when graphics such as leaderheads are used in multiple places.
Combined, this has taken the time to load the disband popup down by more than 80% on first load, and 96% on subsequent loads, from 225 ms on every load to 38 ms (first load), and 8 ms (subsequent loads).
These improvements should be broadly applicable to PCX loads as well, particularly ones that use cropping.
Next I plan to look at implementing some similar improvements for FLC loading.