Page MenuHomeFeedback Tracker

Potential bug in the append command
Need More Info, NormalPublic

Description

The append command appears to be slower than what it can be. It's slower than insert [-1], which does the same thing but (theoretically) slower, due to creating an array for the right argument.

Please change the append command to utilize the new algorithm in insert.

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
Scripting

Event Timeline

repro + times please

BIS_fnc_KK changed the task status from New to Need More Info.Mar 27 2023, 12:25 PM
This comment was removed by BIS_fnc_KK.

Looks like the performance varies a bit. It's not always slower than +. But it is always slower than insert

Run this once to create ar:

ar = [];
for "_i" from 1 to 100 do {
    ar pushBack [_i]; // non-array version is relatively faster; but perf differences remain the same
};

Now try these (uncomment whichever you want to test):

_a = [];
for "_i" from 1 to 3 do {
	 //_a append ar; // 0.0205 ms
	 //_a = _a + ar; // 0.0137 ms
	 //_a insert [-1, ar]; // 0.0172 ms
}

But for larger number of additions, + becomes slower, but insert is still faster:

_a = [];
for "_i" from 1 to 10 do {
	//_a append ar; // 0.0667 ms
	//_a = _a + ar; // 0.0971 ms
	//_a insert [-1, ar]; // 0.0560 ms
}

Cannot confirm. The speed for append on my laptop is very much the same or slightly faster than insert