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.
![](https://secure.gravatar.com/avatar/e34c7ca0f8175dbfd9a08475e7a9fb4e?size=40&default=https%3A%2F%2Fassets.uvcdn.com%2Fpkg%2Fadmin%2Ficons%2Fuser_70-6bcf9e08938533adb9bac95c3e487cb2a6d4a32f890ca6fdc82e3072e0ea0368.png)
-
Роман Волков 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")
}
}