I've been looking into benchmarking the performance cost of different ui mods, and made a minimal ui mod for this purpose.
('OnBeatTimings', uploaded to the mod vault.)
This tells you how long is being spent in UI 'beat functions', on average. (Not the total performance cost of UI mods, in all situations, but something which I think is significant, and which can be measured quite easily.)
To use this, run FAF windowed, open the log viewer and console, set up a benchmark situation, leave it to run for a bit (10 seconds or so) and then enter the following in the console:
This tells you the average time spent in beat functions which are not flagged as 'throttled', per update.
You can also get the average time spent in 'throttled' beat functions, with:
Note that these timings include time spent in built-in beat functions, as well as beat functions in mods you have enabled, but you can disabled and enable mods and see how this affects the timings.
To quickly set up a benchmark situation, I suggest enabling cheats and then using the copy and paste units thing. (So set up a situation with a load of units placed one time. Select the units. Hit ctrl-shift-C to copy placement script for these units. Paste that into a text editor. To place the units back into game for future benchmarking copy the buffer out of your text editor and then ctrl-shift-V in game.)
When looking into the timings coming out of this I found that one built-in beat function in particular, for 'avatar update', was taking a disproportionate amount of the time spent in situations I was benchmarking.
'Avatar update' is for the ui elements normally towards the top right of the screen that show things like ACU health and shield, number of idle engineers, and so on.
I made another 'micro mod', then, to simply remove this update function. ('DisableAvatarUpdate', also uploaded to the vault.) With this mod installed and enabled, the avatars no longer get updated, so no longer work correctly, but this enables us to quickly check the cost of this beat function, and also enables you to reduce your total UI beat function overhead quite significantly, if you are so inclined.
If anyone is interested:
So I'm working on a selection helper mod where I want a given hotkey to sometimes add a unit to the current selection, and sometimes start a new selection, depending on context.
The way I have it set up currently is that, after you made your initial selection, (or add to a selection) it stays in 'incremental selection' mode for a fixed time. So if you press a selection hotkey several times in quick succession you get that many units of that type, but if you wait a certain amount of time before pressing again, it starts a new selection.
The problem with this is that this depends on the user having some idea of the time that has passed since the last key press, which ends up being not so intuitive (in that it will sometimes not do the selection action that the user wanted).
What I would really like is for incremental mode to remain in effect until the current selection is given some command, with selection mode then reverting back, such that the next hotkey press after the command is given starts a new selection.
For this, I need to detect when a command has been given, but I can't see an easy way to this.
Does anyone here know how this can be done (detecting when selected units have been given a command)?
Any other ideas?