Skip to main content
Known Participant
September 16, 2009
Question

How to speed up script loading and processing time?

  • September 16, 2009
  • 1 reply
  • 2144 views

Is there a way to optimize a PS script so that it loads up and elaborates faster?

Of course more RAM and a faster processor, but in terms of code optimization?

Thanks!

This topic has been closed for replies.

1 reply

Inspiring
September 16, 2009

That mostly depends on what the script does. Iterating layers and working with textItems for example can be slow, sometimes very slow.

You can profile your script in ESKT to see how long each part of your code runs. Once you know where the bottleneck is you can try to rewrite that part to speed this up.

c.pfaffenbichler
Community Expert
Community Expert
September 18, 2009

Michael, haven’t You in some other thread provided the code to set the Playback Options to accelerated and toggle Panels to increase speed?

Inspiring
September 18, 2009

The playback functions are from Xbytor

cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };

Stdlib = function Stdlib() {};

Stdlib.setActionPlaybackOptions = function(opt, arg) {
  function _ftn() {
    var desc = new ActionDescriptor();
    var ref = new ActionReference();
    ref.putProperty(cTID("Prpr"), cTID("PbkO"));
    ref.putEnumerated(cTID("capp"), cTID("Ordn"), cTID("Trgt"));
    desc.putReference(cTID("null"), ref );
    var pdesc = new ActionDescriptor();
    pdesc.putEnumerated(sTID("performance"), sTID("performance"), sTID(opt));
    if (opt == "pause" && arg != undefined) {
      pdesc.putInteger(sTID("pause"), parseInt(arg));
    }
    desc.putObject(cTID("T "), cTID("PbkO"), pdesc );
    executeAction(cTID("setd"), desc, DialogModes.NO);
  }
  _ftn();
};
Stdlib.setPlaybackAcclerated = function() {
  Stdlib.setActionPlaybackOptions("accelerated");
};
Stdlib.setPlaybackStepByStep = function() {
  Stdlib.setActionPlaybackOptions("stepByStep");
};
Stdlib.setPlaybackPaused = function(delaySec) {
  Stdlib.setActionPlaybackOptions("pause", delaySec);
};

I may have posted panel functions somewhere but if I did I didn't add them to my code lib and can't find them off hand.

But I think that things like hiding panels and setting the zoom to some small percent only make the script marginally faster. The first step I would take would be to profile in ESTK