As the title says
Description
Details
- Severity
- Tweak
- Resolution
- Open
- Reproducibility
- Always
- Operating System
- Windows 10 x64
- Category
- Scripting
Some code requested by @dedmen
disableSerialization; _display = findDisplay 313 createDisplay "RscDisplayEmpty"; _tv = _display ctrlCreate ["RscTreeSearch", -1]; _tv ctrlSetPosition [0,0.06,1,0.94]; _tv ctrlSetBackgroundColor [0,0,0,1]; _tv ctrlCommit 0; _text = "Some Entry"; _data = "SomeData"; _value = 1337; _fnc_fillTV = { for "_i" from 0 to 20000 do { _index = _tv tvAdd [[], _text]; _tv tvSetData [[_index], _data]; _tv tvSetValue [[_index], _value]; }; tvClear _tv; }; _time = diag_tickTime; for "_loopCount" from 0 to 50 do { call _fnc_fillTV; systemChat str _loopCount; }; systemChat format ["Time passed: %1", diag_tickTime - _time];
Event Timeline
For listbox as requested from @dedmen
disableSerialization; _display = findDisplay 313 createDisplay "RscDisplayEmpty"; _lb = _display ctrlCreate ["RscListbox", -1]; _lb ctrlSetPosition [0,0.06,1,0.94]; _lb ctrlSetBackgroundColor [0,0,0,1]; _lb ctrlCommit 0; _text = "Some Entry"; _data = "SomeData"; _value = 1337; _fnc_fillLB = { for "_i" from 0 to 20000 do { _index = _lb lbAdd _text; _lb lbSetData [_index, _data]; _lb lbSetValue [_index, _value]; }; lbClear _lb; }; _time = diag_tickTime; for "_loopCount" from 0 to 1000 do { call _fnc_fillLB; }; systemChat format ["Time passed: %1", diag_tickTime - _time];
I forgot to close this.
Back then I decided theres nothing to optimize and that most time is actually spent in the script side.
8% time is spent in lbSetData, 6% in lbAdd, 5.5% in lbSetValue.
15% is in reading script variables
11% assigning script variables with = sign.
10% in checking types, when you call the lb* methods, verifying that the types passed into them are allowed for the script commands
8.3% in creating arrays
9% other overhead in executing script commands
5% for the for loop transitioning to next iteration
4% entering and exiting the scope in the for loop
63% just for the script loop.
19% for the lb commands themselves.
And the rest are rounding errors in my profiling data.
The lbAdd itself is 6%
But... I was able to find some other optimization making all scripts faster.
That got this benchmark from 20 seconds down to 18.5. Smol steps