Timing Scripts

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
jsburnett
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 121
Joined: Fri Mar 09, 2007 9:47 pm

Timing Scripts

Post by jsburnett » Mon Feb 02, 2009 10:25 pm

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?

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10045
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Post by FourthWorld » Tue Feb 03, 2009 1:40 am

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
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply