• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Performance of operations in large PSD

Enthusiast ,
Mar 13, 2015 Mar 13, 2015

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

TOPICS
Actions and scripting

Views

439

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Mar 13, 2015 Mar 13, 2015

Copy link to clipboard

Copied

Could you post the Script?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 13, 2015 Mar 13, 2015

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

  • using artLayer.getByName() is much faster and takes only 90ms. Can't use it for everything, but definitely worth optimization to differentiate the cases!
  • strangely using group.layers and adding "if layer.typename == "ArtLayer" only takes 1300ms so worthy optimization
  • storing artLayers.length in local variable speeds it further to 900ms so worth doing
  • storing group.artLayers as local variable had no major change
  • iterating as "for (var layer in group.artLayers) {}" does not seem to work
  • No difference between 32/64bit CC 2012 in Windows
  • CC2014 seems a bit slower (~20%)
  • Mac seems a bit faster (~20%) than Windows

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 13, 2015 Mar 13, 2015

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.

Re: Get all groups and layers with "ActionReference()"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 13, 2015 Mar 13, 2015

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

Script to search layer names | Adobe Community

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 14, 2015 Mar 14, 2015

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 14, 2015 Mar 14, 2015

Copy link to clipboard

Copied

LATEST

Maybe you could start a new thread if any particularly interesting issue turns up.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines