Page 1 of 1

Timing Scripts

Posted: Mon Feb 02, 2009 10:25 pm
by jsburnett
Hi,

I've been working on a few scripts that involve loops and calculations. I was wondering if there was a way to time a script to see if changes in coding really make a difference in speed - especially since some of the calculations will be repeated - and so small decreases in speed could add up.

I've tried millsec - but that does not seem to be sensitive enough.

Ticks are worse.

Any thoughts?

Posted: Tue Feb 03, 2009 1:40 am
by FourthWorld
True, milliseconds are often too granular to see performance differences.

The approach I take is to write a sample script which puts these through a loop for multiple iterations, e.g.:

Code: Select all

on mouseUp
   put 100 into n

   -- test 1:
   put the millisecs into t
   repeat n
        DoSomething
   end repeat
   put the millisecs - t into t1
   --
   -- test 2:
   put the millisecs into t
   repeat n
      DoSomethingElse
   end repeat
   put the millisecs - t into t2
    --
   put t1 && t2
end mouseUp