Revolution speed sucks?
Alex Rice
alrice at ARCplanning.com
Thu Aug 7 16:44:01 EDT 2003
On Thursday, August 7, 2003, at 12:29 PM, yoy wrote:
> The variable testing makes much sense. If the lotto were a Powerball
> lotto,
> I could grab the first 5 items and place them in one variable and put
> the
> sixth item into another variable, test the first variable of 5 numbers
> using
> for each, and test the bonus variable with a simple if x = y then
> colorize
> them as needed and then put them back into the line in the field with
> lock
> screen on.
>
> Is this sound logic?
Andy, sorry "lock screen" helps a little, but it seems you are missing
the big point.
I grabbed the stack from
<http://mywebpages.comcast.net/foxcat/OmniLotto.rev> The mouseup
handler of btn "start" has multiple embedded loops that access fields.
A field is part of the GUI, it is not a proper data structure. The fact
that a field can be used as a source of value (put fld "number" * pi
into fld "result") is a convenience, but is not meant to be used as you
are.
The Perl equivalent of what you are doing would be saving some data to
disk or over a network instead of just using a $variable. That's
exaggerated, but you get the idea. This has to be fixed before you will
have a clear picture of the speed possible with Rev.
Do this instead:
-- not in a loop here
put fld "winners" into theWinners
-- start a loop
repeat for each line in theWinners --note: NOT "each line in fld
winners"
-- do not access any buttons or fields in here
...
end repeat
-- not in a loop here either
put "whatever" into fld "results"
Now look again at your code is the whole thing within another loop that
is accessing a field, like:
"repeat for each line z in fld "gamelist" ?
Here is an experiment: make a stack with 3 buttons and 1 field. Put the
following 3 scripts into the buttons. Button 2 is fastest (5 ms).
Button 1 is the slowest (700 ms). Button 3 is faster (50 ms), but still
off by a factor of 10x.
on mouseup -- of btn 1
put the milliseconds into tStart
repeat with x = 1 to 1000
put x * 2 into fld 1 -- bad
end repeat
put "elapsed: " & (the milliseconds) - tStart into fld 1
end mouseup
on mouseup -- of btn 2
put the milliseconds into tStart
repeat with x = 1 to 1000
put x * 2 into tmp -- not a field
end repeat
put "elapsed: " & (the milliseconds) - tStart into fld 1
end mouseup
on mouseup -- of btn 3
lock screen -- helps a little
put the milliseconds into tStart
repeat with x = 1 to 1000
put x * 2 into fld 1 -- bad
end repeat
put "elapsed: " & (the milliseconds) - tStart into fld 1
end mouseup
Alex Rice, Software Developer
Architectural Research Consultants, Inc.
http://ARCplanning.com
More information about the use-livecode
mailing list