9 Replies Latest reply on Jul 6, 2014 8:08 PM by hasvi

    Script Running time log report

    hasvi Level 1

      Hi,

       

      Is there any possibilities to take the run time report for script running process. For instance I have to collect my script running time to close time as in log report.

       

      by

      hasvi

        • 1. Re: Script Running time log report
          Chinnadk Level 4

          Hi Hasvi,

           

          Try this.

           

          var start = new Date().getTime();
          
          //Your scripts goes here.
          
          var end = new Date().getTime();
          var time = end - start;
          alert("Execution time in seconds: " + time/60);
          

           

          Regards,

          Chinna

          • 2. Re: Script Running time log report
            Jump_Over Level 5

            Hi,

             

            Notice that time is a number of miliseconds, so it supposed to be:

                 alert("Execution time in seconds: " + time/1000);

             

            Jarek

            • 3. Re: Script Running time log report
              hasvi Level 1

              Hi,

               

               

              I have check with one script, finally its showing alert message "Execution time in seconds: 338.258". Suddenly I can’t understand this time, is there any easy way to get time "Hours: Minutes: Seconds"

               

              See below the calculation and its Result:

              alert("Execution time in seconds: " + time/1000)-->Execution time in seconds: 338.258

              alert("Execution time in seconds: " + time/60)-->Execution time in seconds: 6345.05

               

               

              by

              hasvi

              • 4. Re: Script Running time log report
                Chinnadk Level 4

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

                 

                //Your scripts goes here.

                 

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

                var time = end - start; 

                var seconds = Math.round(time/1000),

                var minutes = Math.round(seconds/60);

                var hr = Math.round(minutes/60);

                 

                alert(hr + ":" + minutes + ":" + seconds);

                • 5. Re: Script Running time log report
                  hasvi Level 1

                  Hi,


                  Error showing "Illegal use of reserved word 'var'

                  on line "var minutes = Math.round(seconds/60);"


                  FYI:


                  1.png

                  by

                  hasvi

                  • 6. Re: Script Running time log report
                    Chinnadk Level 4

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

                     

                    //Your scripts goes here.

                     

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

                    var time = end - start;

                    var seconds = Math.round(time/1000);

                    var minutes = Math.round(seconds/60);

                    var hr = Math.round(minutes/60);

                     

                    alert(hr + ":" + minutes + ":" + seconds);

                    • 7. Re: Script Running time log report
                      hasvi Level 1

                      I really admire your script. Thanks chinna

                       

                      by

                      hasvi

                      • 8. Re: Re: Script Running time log report
                        Jump_Over Level 5

                        Hi,

                         

                        Hm... this code say true only for time lower than 1 minute (< 30 sec in fact, since round goes up).

                         

                        Notice that number of hours, minutes and second should be calculated as a PARTS of a bigger sum.

                        Otherwise adding hr + minutes + seconds gives us a time 3 times bigger (more or less around).

                         

                        So,

                        var start = new Date().getTime();
                        //Your scripts goes here.
                        var
                            end = new Date().getTime(),
                            time = end - start,
                            mH = ("0" + Math.floor(time/3600000) ).slice(-2),     //     upto 99 hours be awared
                            mM = ("0" + Math.floor( (time%3600000) / 60000 ) ).slice(-2),
                            mS = ("0" + (time%60000) / 1000).slice(-2);
                        
                        alert(mH + ":" + mM + ":" + mS);
                        
                        
                        
                        

                         

                        Jarek

                        • 9. Re: Script Running time log report
                          hasvi Level 1

                          Hi,

                           

                          1. I had run the below script:

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

                          var myDocument = app.activeDocument;

                           

                           

                          myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches;

                          myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches;

                          myDocument.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;

                          myDocument.textPreferences.superscriptPosition=33;

                          myDocument.textPreferences.superscriptSize=70;

                          myDocument.textPreferences.subscriptPosition=33;

                          myDocument.textPreferences.subscriptSize=70;

                          myDocument.textPreferences.smallCap=75;

                          app.imePreferences.inlineInput=true;

                           

                           

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

                          var time = end - start;

                          var seconds = Math.round(time/1000);

                          var minutes = Math.round(seconds/60);

                          var hr = Math.round(minutes/60);

                           

                          alert(hr + ":" + minutes + ":" + seconds);

                           

                               result is 0:0:0. because its running running within fraction of seconds.

                           

                          2. I had run the below script

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

                          var myDocument = app.activeDocument;

                           

                           

                          myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches;

                          myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches;

                          myDocument.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;

                          myDocument.textPreferences.superscriptPosition=33;

                          myDocument.textPreferences.superscriptSize=70;

                          myDocument.textPreferences.subscriptPosition=33;

                          myDocument.textPreferences.subscriptSize=70;

                          myDocument.textPreferences.smallCap=75;

                          app.imePreferences.inlineInput=true;

                           

                           

                          var 

                              end = new Date().getTime(), 

                              time = end - start, 

                              mH = ("0" + Math.floor(time/3600000) ).slice(-2),     //     upto 99 hours be awared 

                              mM = ("0" + Math.floor( (time%3600000) / 60000 ) ).slice(-2), 

                              mS = ("0" + (time%60000) / 1000).slice(-2); 

                           

                          alert(mH + ":" + mM + ":" + mS); 

                           

                          result is 00:00:19. Heare what is 19, because this script is running within fraction of seconds.

                           

                          by

                          hasvi