If you come up with two or more approaches on how to solve a
particular problem and you are not sure which would be faster, then
you can easily construct a speedtest to see which is best. The basic
way to do this is to code two or more different algorithms (usually
repeating many times to get a good sample) and measure the time it
takes to complete them. Like this:
on SpeedTest
millisecondsStart = the milliseconds
repeat with i = 1 to 1000 -- or 10000 or 1000000 depending on algorithm
-- do algorithm 1 here
end repeat
millisecondsElapsed = the milliseconds - millisecondsStart
put "Algorithm 1 took" && millisecondsElapsed && "milliseconds
millisecondsStart = the milliseconds
repeat with i = 1 to 1000 -- or 10000 or 1000000 (same as above)
-- do algorithm 2 here
end repeat
millisecondsElapsed = the milliseconds - millisecondsStart
put "Algorithm 2 took" && millisecondsElapsed && "milliseconds
end
Then, run your speedTest by typing "SpeedTest()" into the message window.
Choose the one with the lower number
Irv
At 12:02 PM -0500 10/29/01, Genevieve Young wrote:
>
>
>Lingo algorithms may be written in many different ways. Some of
>these ways perform faster than others. How do we go about using
>benchmark tests to compare these algorithms? Should we be doing this?
>
--
Lingo / Director / Shockwave development for all occasions.
(Home-made Lingo cooked up fresh every day just for you.)
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list,
email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo. Thanks!]