Iterating through large collections is very slow (non linear).
Whenever I have a need to iterate through a large collection (such as pageItems) the iteration is very very slow, and the larger the collection is the more slower it gets. I would expect this to be a linear behavior, but it's not. If a collection's size doubles, it takes more than double the time to iterate through it.
-
Роман Волков commented
Adobe Illustrator is running slower and slower with each new version :(((
-
Vitaly Polyakov commented
I have such a problem. I checked Illustrator versions 16.2.0, 26.4.1, 27.0 - the problem is reproduced.
For example generate a file with a lot of objects using generate_rectangles.jsx
Then run test_collection.jsx
I got the following results:
Access time to pageItems[0] - 0.002 sec
Access time to pageItems[100000] - 0.02 secgenerate_rectangles.jsx
------------
var count = 100001;
for (var i = 0; i < count; i++) {
app.activeDocument.pathItems.rectangle(0,0,100,100);
if (i % 100 == 0)
$.writeln(i);
}
------------
test_collection.jsx
------------
var pi = activeDocument.pageItems;
for (var i = 0, len = pi.length; i < len; i+=100) {
$.hiresTimer
pi[i].name = i;
if (i % 100 == 0){
var time = $.hiresTimer/1000000;
$.writeln(i+": " + time.toFixed(4) + " seconds")
}
}