• 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 script?

Explorer ,
Jun 15, 2017 Jun 15, 2017

Copy link to clipboard

Copied

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

TOPICS
Actions and scripting

Views

1.9K

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

Adobe Employee , Jun 15, 2017 Jun 15, 2017

var totalTime = new TimeIt();

... do cool stuff ...

totalTime.stop();

// log it out

totalTime.getTime();

function TimeIt() {

  // member variables

  this.startTime = new Date();

  this.endTime = new Date();

  // member functions

  // reset the start time to now

  this.start = function () {

        this.startTime = new Date();

    }

  // reset the end time to now

  this.stop = function () {

        this.endTime = new Date();

    }

  // get the difference in milliseconds between start and stop

  this.getTime = f

...

Votes

Translate

Translate
Adobe
Adobe Employee ,
Jun 15, 2017 Jun 15, 2017

Copy link to clipboard

Copied

var totalTime = new TimeIt();

... do cool stuff ...

totalTime.stop();

// log it out

totalTime.getTime();

function TimeIt() {

  // member variables

  this.startTime = new Date();

  this.endTime = new Date();

  // member functions

  // reset the start time to now

  this.start = function () {

        this.startTime = new Date();

    }

  // reset the end time to now

  this.stop = function () {

        this.endTime = new Date();

    }

  // get the difference in milliseconds between start and stop

  this.getTime = function () {

        return (this.endTime.getTime() - this.startTime.getTime()) / 1000;

    }

  // get the current elapsed time from start to now, this sets the endTime

  this.getElapsed = function () {

        this.endTime = new Date(); return this.getTime();

    }

}

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

Copy link to clipboard

Copied

Thanks a lot for answering!!! But, sorry for misunderstanding!!! It was my fault when formulating the question! I need a script to measure the execution time of Photoshop Actions. Sorry!!!

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
Adobe Employee ,
Jun 15, 2017 Jun 15, 2017

Copy link to clipboard

Copied

Create a jsx file with the code above.

Replace this line:

... do cool stuff ...

whit this line:

doAction("ActionName", "ActionSetName");

replace the last line with:

alert(totalTime.getTime());

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

Copy link to clipboard

Copied

All working!!! Thank you so much!!!!

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

I suggest use high resolution timer or buil-in profiler in extend script toolkit.

$.hiresTimer

reading this timer get time of script execution and it also reset timer. So I suggest do first dummy reading for reseting timer at some point and second reading will show you how much time script spend since first reading.

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

Thank you for answering, but I am new to scripting hence I do not understand how and where to use    $.hiresTimer  to solve my issue in Photoshop...

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

Copy link to clipboard

Copied

//reset timer

$.hiresTimer;

//something you want measure

var a = app.activeDocument.artLayers.add();

var b = app.activeDocument.artLayers.add();

var c = app.activeDocument.artLayers.add();

//show message and read time

alert("Time: "+($.hiresTimer/1000000)+"s");

//reset timer beacause we don't want measure how long take click to "OK" button

$.hiresTimer;

//something you want measure

a.remove()

b.remove()

c.remove()

//show message and read time

alert("Time: "+($.hiresTimer/1000000)+"s");

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

I want to measure the time of a Photoshop Action... like doAction("ActionName", "ActionSetName");

What strings should I use instead of

var a = app.activeDocument.artLayers.add();

and

a.remove()

Thank you very much for helping me!!!

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

Copy link to clipboard

Copied

LATEST

There would be lines of code... something like you wrote. I don't know how to run recorded action.

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