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.
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
...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();
}
}
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!!!
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());
Copy link to clipboard
Copied
All working!!! Thank you so much!!!!
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.
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...
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");
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!!!
Copy link to clipboard
Copied
There would be lines of code... something like you wrote. I don't know how to run recorded action.