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

How can I measure the execution time of a Photoshop Action?

Explorer ,
Jun 15, 2017 Jun 15, 2017

Copy link to clipboard

Copied

I have several time-consuming Photoshop Actions and want to adjust them. Execution time is a measure of Action efficiency for my goals. Hence, I want to measure the execution time of a Photoshop Actions.  Any help would be highly appreciated.

TOPICS
Actions and scripting

Views

707

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

correct answers 1 Correct answer

Community Expert , Jun 16, 2017 Jun 16, 2017

I did not post my action timer script because Adobe design in an intentional bug in Photoshop CC 2015.5 Scripting.  It one thing to let a bug out  unknowingly I do not why Adobe did it.   The reason the posted was it bad to remove metadata like copyright information.  Yet Photoshop save for web does that by default.  I do not do that I try to remove my metadata however, Adobe scripting will no longer set a metadata files to empty its default state.  I can use Photoshop Adobe File Info  to set Co

...

Votes

Translate

Translate
Adobe
Community Expert ,
Jun 15, 2017 Jun 15, 2017

Copy link to clipboard

Copied

You could write what I call run twice script. These script are written to be used in an actions twice.  You can think of them as a save and restore or recover function for actions that process documents.  The first time the action uses the script the script finds that it has not saved the information in the documents metadata and stores its marker and information to be saved in the document's metadata.  The second time the action uses the script It retrieves the information it stored in the documents metadata, removes its market and saved data from the document metadata and uses the retrieved data to do something.    Like save Photoshop's units settings and the document resolution.  The Action can then change  these Change Photoshop ruler units and scale the document to a particular width without resampling only hange the document resolution.  Add a layer to the document that is that wide  The second time run the script restores the users Photoshop ruler units setting and the documents resolution. 

Your script would store the current time the first run. The second run it would get the current time and retrieve the save time and display the amount of time it took. Once you have the script written and run it twice in an action you will know how long it takes an action to run the script twice. You then Add the these two script steps to actions you want to time. As their First and last action steps.

JJMack

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 ,
Jun 16, 2017 Jun 16, 2017

Copy link to clipboard

Copied

I did not post my action timer script because Adobe design in an intentional bug in Photoshop CC 2015.5 Scripting.  It one thing to let a bug out  unknowingly I do not why Adobe did it.   The reason the posted was it bad to remove metadata like copyright information.  Yet Photoshop save for web does that by default.  I do not do that I try to remove my metadata however, Adobe scripting will no longer set a metadata files to empty its default state.  I can use Photoshop Adobe File Info  to set Copyright data to anything that I want it does not make the image mine nor does Copyright info protect  anyone's image the Law  and the courts do that. I get around Adobe bug by adding Garbage in every document I edit info metadata field using Adobe Script event manager.  So all my run twice scripts will work in CC 2015.5 and CC 2017.

It will add a little over a second to your actions play time.

Capture.jpg

So here my script if it does not work for you its Adobe's bug not my code.

/* =============================================================================================

// 2010  John J. McAssey (JJMack)  http://www.mouseprints.net/

// 

// This script is supplied as is. It is provided as freeware.

// The author accepts no liability for any problems arising from its use.

//

// This script is designed to be used by a Photoshop Action twice

// A good pratice to use when creating an actions that use this scipt is for the action

// not to do a save or play some other action between its two useages of this Script.

//

// The first time this script is used by an action the currend date and time

// are saved into the document's meta-data Info Instructions field.

//

// The second time this script used by the action this script retreives the date and time

// that was saved in the meta-data during the first usage.

// The script Outputs an Action duration message to Alerts the user of the time it took.

// Logs the Action Times into the ActionTime.log file in the folder where the script resides.

// Then the saved date and time is removed from the document's meta-data Info Instructions field.

//

// ============================================================================================== */

/*

<javascriptresource>

<about>$$$/JavaScripts/ActionTime/About=JJMack's ActionTime^r^rCopyright 2010 Mouseprints.^r^rRun twice script utility for action.^rNOTE:Don't play other actions between runs!^r^rFirst Run records Actions Start Time.^rSecond Run removes start time recording and outputs an execution time message.</about>

<enableinfo>true</enableinfo>

<category>JJMack's Action Run Twice Utility</category>

</javascriptresource>

*/

if (app.documents.length > 0) { // LOGFile faild trying this --> app.activeDocument.suspendHistory('ActionTime','main()');

  if (app.activeDocument.info.instructions.indexOf("<ActionTime>") == -1 ){ // no footprint fisrt useage

  //alert("first");

  // Retreive Date Time for Foot Print

  var stime = new Date().getTime();

  //alert("Time = " + stime );

  StartTime = timeStamp() ;

  // put footprint in metadata info instructions

  app.activeDocument.info.instructions = app.activeDocument.info.instructions + "<ActionTime>" + StartTime + "</ActionTime>" + "<ClockTime>" + stime + "</ClockTime>";

  //alert( "Saved ="  + "<ActionTime>" + StartTime + "</ActionTime>"+ "<ClockTime>" + stime + "</ClockTime>");

  }

  else {

  //alert("second");

  var etime = new Date().getTime();

  //alert("Time = " + etime );

  EndTime = timeStamp();

  // Retreive saved information

  ActionTimeOffset = app.activeDocument.info.instructions.indexOf("<ActionTime>") + "<ActionTime>".length;

  ActionTimeLength = app.activeDocument.info.instructions.indexOf("</ActionTime") -ActionTimeOffset;

  StartTime = app.activeDocument.info.instructions.substr(ActionTimeOffset, ActionTimeLength);

  ClockTimeOffset = app.activeDocument.info.instructions.indexOf("<ClockTime>") + "<ClockTime>".length;

  ClockTimeLength = app.activeDocument.info.instructions.indexOf("</ClockTime") -ClockTimeOffset;

  stime = app.activeDocument.info.instructions.substr(ClockTimeOffset, ClockTimeLength);

                duration = ((etime - stime)/1000);

  alert("ActionTime \rStart = " + StartTime  + " \rEnd   = " +  EndTime + " \rTime = " +  duration + " Seconds");

  // Log Edit Session into Log File

  var scriptLocation = findScript()+ "0";

                var LOGFilePath = scriptLocation.slice(0,-4) + "log";

                var LOGFile = File(LOGFilePath);

  writeLOG(app.activeDocument.name + " Start=" + StartTime  + " End=" +  EndTime + " Time=" +  duration + " Seconds\r")

  // End log File

  // Remove footprint from metadata info instructions

  before = app.activeDocument.info.instructions.substr(0,app.activeDocument.info.instructions.indexOf("<ActionTime>"));

  afterOffset = app.activeDocument.info.instructions.indexOf("</ClockTime>") + "</ClockTime>".length;

  after = app.activeDocument.info.instructions.substr(afterOffset, app.activeDocument.info.instructions.length - afterOffset);

  //alert ("before = " + before + " after = " + after);

  app.activeDocument.info.instructions = before + after;

  }

}

else { alert("You must have at least one open document to run this script!"); }

///////////////////////////////////////////////////////////////////////////////

//       main function

///////////////////////////////////////////////////////////////////////////////

function main(){

}

///////////////////////////////////////////////////////////////////////////////

// END - main function

///////////////////////////////////////////////////////////////////////////////

function timeStamp(){

  // Get the time and format it

  var digital = new Date();

  var hours = digital.getHours();

  var minutes = digital.getMinutes();

  var seconds = digital.getSeconds();

  var amOrPm = "AM";

  if (hours > 11) amOrPm = "PM";

  if (hours > 12) hours = hours - 12;

  if (hours == 0) hours = 12;

  if (minutes <= 9) minutes = "0" + minutes;

  if (seconds <= 9) seconds = "0" + seconds;

  // Get the date and format it

  var date = new Date();

  var d  = date.getDate();

  var day = (d < 10) ? '0' + d : d;

  var m = date.getMonth() + 1;

  var month = (m < 10) ? '0' + m : m;

  var yy = date.getYear();

  var year = (yy < 1000) ? yy + 1900 : yy;

  // create a variable with the fully formatted the time and date

  // todaysDate = hours + ":" + minutes + ":" + seconds + " " + amOrPm + " - " + day + "/" + month + "/" + year;

  // todaysDate = hours + ":" + minutes + ":" + seconds + " " + amOrPm + " - " + month + "/" + day + "/" + year;

  MonthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");

  todaysDate = hours + ":" + minutes + ":" + seconds + " " + amOrPm + " " + MonthNames[date.getMonth()] + " " + date.getDate() + ", " + year;

        return todaysDate;

}

// Find the location where this script resides

function findScript() {

  var where = "";

  try {

  FORCEERROR = FORCERRROR;

  }

  catch(err) {

  // alert(err.fileName);

  // alert(File(err.fileName).exists);

  where = File(err.fileName);

  }

  return where;

}

// Write LOG file

    function writeLOG(log) {

        try {

            if(LOGFile.exists) {

                LOGFile.open ("e");

                LOGFile.seek (0,2);      // Move to EOF

            } else {

            LOGFile.open ("w");          // Add unicode marker if we change to LOG file format for this log file

        }

        LOGFile.encoding = "UTF8"; // set UTF8

        LOGFile.write(log);

        LOGFile.close();

        } catch (e) {

            alert(e);

        } finally {

        }

        return;

    }

.

JJMack

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
Explorer ,
Jun 17, 2017 Jun 17, 2017

Copy link to clipboard

Copied

Thank you very much for answering!!! HIGHLY APPRECIATED!!! It works!!!

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 ,
Jun 18, 2017 Jun 18, 2017

Copy link to clipboard

Copied

Here is the script to add garbage with the Script Even manager in CC 2015.5 and CC 2017.  Set New document and open document events to run this script to get around Adobe intentional Bug.

Garbage.jsx

if (app.activeDocument.info.instructions.indexOf("Garbage") == -1 ) app.activeDocument.info.instructions = app.activeDocument.info.instructions + "Garbage";

JJMack

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
Explorer ,
Jun 18, 2017 Jun 18, 2017

Copy link to clipboard

Copied

LATEST

Thank you!

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 ,
Jun 16, 2017 Jun 16, 2017

Copy link to clipboard

Copied

Recorded actions should be equal with code generated with script listener.

1) use script listener

2) do your task same as you would record action

3) copy/paste recorded code into Extend Script toolkit

4) run your code in extend script toolkit with profiling turned on

5) show timing data for each line

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