Page MenuHomeFeedback Tracker

Investigate if tvAdd can be made quicker.
Closed, ResolvedPublic

Description

As the title says

Details

Severity
Tweak
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
Scripting
Steps To Reproduce

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

R3vo created this task.Nov 24 2020, 1:51 PM
R3vo edited Steps To Reproduce. (Show Details)
R3vo renamed this task from Investigate if tvAdd can made quicker. to Investigate if tvAdd can be made quicker..
R3vo added a subscriber: dedmen.
dedmen claimed this task.Nov 24 2020, 1:54 PM
dedmen changed the task status from New to Assigned.
dedmen set Ref Ticket to AIII-53601.
R3vo added a comment.Nov 24 2020, 4:03 PM

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];
dedmen added a comment.Jul 5 2024, 4:53 PM

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%

dedmen closed this task as Resolved.Jul 5 2024, 4:53 PM
dedmen added a comment.Jul 5 2024, 8:30 PM

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