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

Performance profiling

Participant ,
Dec 08, 2017 Dec 08, 2017

Copy link to clipboard

Copied

Any way to profile performance of JSX layer to find bottlenecks?

I noticed that on Windows 10 my script is running significantly slower than on MacOS.

Still, on both platforms it would be great to profile and find which methods take the longest to run and where are the bottlenecks.

Any tools already available for that?

TOPICS
Actions and scripting

Views

789

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
Dec 08, 2017 Dec 08, 2017

Copy link to clipboard

Copied

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();

    }

}

a = new TimeIt();

...

a.getElapsed();

There is also $.hiresTimer but I've never used it.

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
People's Champ ,
Dec 09, 2017 Dec 09, 2017

Copy link to clipboard

Copied

You can also try

function init_log()

    {

    _timer_log_ = new Array();

    _last_line_ = 1;

    $.hiresTimer;

    }

function log_delay(l)

    {

    var time = $.hiresTimer/1000000;

    _timer_log_.push([time,  "line " + _last_line_ + " to " + l + " \tdelay = " + time.toFixed(3)]);

    _last_line_ = l;

    }

function show_log()  

    {

    function cmp(a, b) {if (a[0] < b[0]) return 1; if (a[0] > b[0]) return -1; return 0; }

    _timer_log_.sort(cmp);

    var s = "";

    for (var i in _timer_log_) s += _timer_log_[1] +" \n";

    alert(s); 

    }

// example of your script

init_log();

app.activeDocument.channels[0].histogram; //example of your code

log_delay($.line)

app.activeDocument.channels[1].histogram; //example of your code

app.activeDocument.channels[2].histogram; //example of your code

log_delay($.line)

app.activeDocument.histogram; //example of your code

log_delay($.line)

// ...the other part of the code

// log_delay($.line)

// ...the other part of the code

// log_delay($.line)

show_log();

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
Engaged ,
Dec 11, 2017 Dec 11, 2017

Copy link to clipboard

Copied

LATEST

The ExtendScript ToolKit (ESTK) has a dedicated profiling tool, that is documented on page 35,36 of the JavaScript Tools Guide.pdf – you should be able to find it in the ESTK own folder.

Davide

Davide Barranca - PS developer and author
www.ps-scripting.com

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