3 Replies Latest reply on Dec 11, 2017 7:35 AM by Davide_Barranca

    Performance profiling

    AverinAAA

      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?

        • 1. Re: Performance profiling
          Tom Ruark Adobe Employee

          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.

          • 2. Re: Performance profiling
            r-bin Level 5

            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_[i][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();
            
            
            1 person found this helpful
            • 3. Re: Performance profiling
              Davide_Barranca Level 1

              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