Revolution speed sucks?

Brian Yennie briany at qldlearning.com
Tue Aug 5 23:31:01 EDT 2003


 From a first glance, these tips should buy you an initial speedup, and 
are mostly GUI-related.

1) Don't read line-by-line through a field. Instead of:

repeat for each line gameLine in fld "gamelist"

do this:

put fld "gamelist" into gameList
repeat for each line gameLine in gameList

You also refer to > line n in fld "gamelist" < when you already have 
this available as "gameLine"

2) Don't update the scrollbar bar in every loop. Only set the visible 
property once, and only update the thumb value if it has actually 
changed by at least 1%. I commented out the scrollbar updating, and the 
script ran as much as 40% faster.

3) Consolidate your repeat loops

For starters, it's look like you loop through the entire list twice: 
combine these loops.

In your second loop, you have three loops inside of each other- and it 
looks to me like the inner most one doesn't work right.

It looks like you are checking if *any* number in your pick matches 
*any* number in the winning combination. Instead of checking 1 match 
(i.e. does item 3 match item 3), you are checking 6- that's a 6 fold 
speedup right there.

4) Check your duplicate number code

You have something like this:

repeat with i=1 to x
    repeat with j=2 to x
        if (item i of z = item j of z) then ## duplicate

I think you want:

repeat with i=1 to x
    repeat with j=(i+1) to x
        if (item i of z = item j of z) then ## duplicate

i.e. You don't need to compare every number to every other number- once 
the 2nd number has been compared to the 5th, the 5th doesn't have to be 
compared again to the 2nd. I think this is what you intended with the 
2, but as it stands you're still doing 15 comparisons on every line 
that aren't necessary.

Implement those concepts and you should be getting closer. Keep in mind 
that GUI is much more expensive than raw processing, minimizing repeat 
loops goes a long way, etc, and you should be catching up with Perl 
sooner than later...

Have fun!

Brian


> I ran my stack "OmniLotto" and generated 5000 random powerball games. 
> Then
> it ran. It .took over 30 minutes!!!
>
> I saved the 5000 gamelist and ran it through my PERLotto perl script 
> out to
> "results.txt".
>
> It took only 1 second!!!!!!!
>
> What gives? Are my script routines way out of order? It certainly 
> seems so!
>
> GEEZ......... Day 5 (?)  gonzo.
>
> Andy
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>




More information about the use-livecode mailing list