Copy link to clipboard
Copied
Has anyone noticed rapid deterioration of performance in reading text layer content (i.e. accessing 'artLayer.textItem.contents')? I mean it's a generic thing that as PSD grows, operations on that become slower, but text layer content seems to go down really badly. In a almost empty PSD operation takes ~20ms, but in a medium/large PSD (100mb / 80 layers) it takes 2700ms! It's not totally obvious why slows down so much as other document operations (e.g. find right layer in doc) don't slow so much.
So not expecting solution, but would like to hear if you have any performance tips/tricks/best practices to share
Copy link to clipboard
Copied
Could you post the Script?
Copy link to clipboard
Copied
Started cleaning the relevant code and noticed I had the the layer selection (loop through layerSet.artLayers) in the measurement and turns our that was the culprit and not the artLayer.textItem.contents! Makes more sense (i.e. more layers means slower), but is worrysome as it's really pervasive and hard to get rid of. Also it's a bit alarming that it seems to be based on doc size, not group size. This was group with 6 layers, no children and looping through them like below takes 2700ms
for (var i=0; i < group.artLayers.length; i++) {
var layer = group.artLayers
// do stuff with layer
Now dug deeper and turns out there are lots of things to improve
I do a lot of finding layers with certain prefix/regex which looks like a big performance hole. Never thought this would be so big and was wondering if you could do this in AM code?
Copy link to clipboard
Copied
storing artLayers.length in local variable speeds it further to 900ms so worth doing
Recently Tom Ruark remarked on that.
Copy link to clipboard
Copied
I do a lot of finding layers with certain prefix/regex which looks like a big performance hole. Never thought this would be so big and was wondering if you could do this in AM code?
AM code often is faster than DOM code, check out the code Mike offered at
Copy link to clipboard
Copied
Thanks on both links! Need to do some more profiling what the actual bottlenecks are and look into optimizing those.
Copy link to clipboard
Copied
Maybe you could start a new thread if any particularly interesting issue turns up.