Speed up a slow loop

J. Landman Gay jacque at hyperactivesw.com
Sun Mar 6 17:56:19 EST 2022

On 3/6/22 1:43 PM, Alex Tweedly via use-livecode wrote:
> Another thought on this problem; I think worth discussing even if the various suggestions so 
> far have already got you a solution. I think it's a general observation ...
> You don't really care how long it takes to do this.
> What you care about is how long the user has to wait for your (the app's) response.
> So don't wait until the user has found all their possible words (i.e. the app is doing 
> effectively nothing for the 30 seconds or so that the user gets for each board). Check each 
> word as they type it, and store the result. Then, when the 30-sec timer is up, you will have 
> only one or two last words to test - all the others have already been checked.
> So you never care about how long it takes to check 50 or so words against the dictionary - you 
> check 49 of them one-at-a-time during the time you are otherwise idle. And the user has only to 
> wait for the negligible delay while you check one or two words.

Good point for later. I was just testing on my Pixel 5, which was slow as hell before, and it 
just verified and marked up a user list of 108 words in 0 ms. I'm astonished at what we've done 
here. The longest word list I've been able to produce has about 225 words, so if it takes an 
extra ms I'm okay with that.

If it ain't broke...

The board walk took 179 ms for all 108 words because I ditched my old, juvenile, inefficient 
code and swiped yours. :) As Bill requested, I've marked all the stuff I used with credits for 
the people who suggested or provided code, so you're in there. The two most impactful changes 
were your board walk and Quentin's filtered dictionary idea, but there are also other improvements.

The one thing I still dont understand is why responses were so fast on my old Android tablet 
before I made changes. It's happy with the new code but there's little discernable difference 
in response time.

Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com

More information about the use-livecode mailing list