Re: Speed up a slow loop

2022-03-15 Thread J. Landman Gay via use-livecode
On 3/14/22 2:09 PM, J. Landman Gay via use-livecode wrote: I've updated the zip file download to include the resources needed; icons for all platforms (but the Windows one is very old) and a copy of the font. Update your standalone settings to accomodate the paths you need. Sorry, wrong link

Re: Speed up a slow loop

2022-03-14 Thread J. Landman Gay via use-livecode
One last thing. Scott Morrow was good enough to build for iOS and send a screenshot. I was very pleased to see it went cross-platform without any significant problems (thank you LC!) but the custom font was missing, which makes sense since I didn't include any external resources. That reminded

Re: Speed up a slow loop

2022-03-12 Thread J. Landman Gay via use-livecode
I have to thank everyone who helped me figure out my Boggle game. I've put the current file on Google Drive for anyone who wants to take a look. The scripts are open and I think I've removed all the testing cruft that accumulated over the last couple of weeks. I'd be interested in any feedback

Re: Speed up a slow loop

2022-03-10 Thread J. Landman Gay via use-livecode
On 3/9/22 5:09 PM, Alex Tweedly via use-livecode wrote:  - you can reuse the same tile later in a word (e.g. Y  L  A X  E  T would allow "lately" as a word. OR - you can double-up on a tile (e.g. M I L would allow 'mill') (more important if you're British than if you're American :-)

Re: Speed up a slow loop

2022-03-09 Thread J. Landman Gay via use-livecode
My memory checks on the Pixel 5 had a maximum app memory use of about 375 MB of RAM. I think that was before I removed the duplicate copy of the dictionary data though, which if so would bring the total down. That said, other apps had more. Chrome browser used over 300 MB, Play Store 411 MB,

Re: Speed up a slow loop

2022-03-09 Thread Neville Smythe via use-livecode
I just ran a test to try to find out how much RAM is used when you create a large array; the result is rather surprising. BTW Bob: I did not imply that an array is implemented in LC as a database. Merely that to work its magic it must be indexing keys somehow. I had suggested a 2.5 MB list

Re: Speed up a slow loop

2022-03-09 Thread Alex Tweedly via use-livecode
Hmmm - I have to correct myself :-) It's not 110; there are 144 digraphs on a 5x5 board  - nine centre tiles each have 8 neighbours  - four corner tiles each have 3 neighbours  - twelve remaining edge tiles each have 5 neighbours giving 72 + 12 + 60 - so 144 pairs (already including both

Re: Speed up a slow loop

2022-03-09 Thread Alex Tweedly via use-livecode
Yes, Quentin's allowing for diagonals (that's how the number of digraphs on a 5x5 board gets up to 110). And it's probably a good idea, allowing an even finer filter - if you aren't doing the boardwalk method.. If you do use the boardwalk to generate the exact list of words, you get no

Re: Speed up a slow loop

2022-03-09 Thread J. Landman Gay via use-livecode
I'm not sure I followed all that, but did you account for diagonals? It sounds like you'd need to calculate all the possible polygons in a 5x5 grid, starting from anywhere, and sometimes wrapping around itself. I don't have the math skills to do that but when I get this thing presentable you

Re: Speed up a slow loop

2022-03-09 Thread J. Landman Gay via use-livecode
On 3/8/22 5:56 PM, Neville Smythe via use-livecode wrote: reducing the list to around 20K words evidently removes the issue, which suggests multiple copies of the array are being created somewhere in (Jacque’s original ) search algorithm. Yeah, I was keeping two copies without realizing it.

Re: Speed up a slow loop

2022-03-09 Thread Bob Sneidar via use-livecode
Hmmm... I think I misread you to say that arrays are indexed. If that were the case, then the devs *should* be able to create functions for querying them and getting a subset of keys. I think then that this is NOT the case. Bob S > On Mar 9, 2022, at 07:57 , Bob Sneidar via use-livecode >

Re: Speed up a slow loop

2022-03-09 Thread Bob Sneidar via use-livecode
Then why isn't there a method to query an array? That was precicely why I wrote the routines to convert an array to a database. Bob S > On Mar 8, 2022, at 15:56 , Neville Smythe via use-livecode > wrote: > > Turning the list into an array will add indexing overhead very similar to > what

Re: Speed up a slow loop

2022-03-08 Thread Quentin Long via use-livecode
It occurs to me that any word which is valid in Boggle must consist of an uninterrupted run of letters which are *right next to each other* on the board. Hence, any digraph which *doesn't* consist of a pair of neighboring letters, *cannot* occur in any valid word. Since the "filter out all

Re: Speed up a slow loop

2022-03-08 Thread Neville Smythe via use-livecode
> On 9 Mar 2022, at 4:00 am, Alex Tweedly wrote: > > I guess I'm not convinced about VM space thrashing being the problem, > certainly not due to the wordlist. It's 2.5 Mb - i.e. 0.02% of the real > RAM in a Pixel 5. There may be something else in the app making the > total VM space very

Re: Speed up a slow loop

2022-03-08 Thread J. Landman Gay via use-livecode
On 3/8/22 3:22 PM, Quentin Long via use-livecode wrote: Does it*matter* whether a genuine word isn't on the board? If the board has no "L" in it, any word with an "L" won't be on the board, right? Right, but what happens is that your eye tricks you and you skip a tile inadvertently or use

Re: Speed up a slow loop

2022-03-08 Thread Neville Smythe via use-livecode
> On 9 Mar 2022, at 4:00 am,Alex Tweedly wrote: > > Oh, well, if you've got the fast boardwalk code in there anyway, that > opens up another possibility (with one caveat). > > The boardwalk will find all valid words on the board. So that list of > words can be used as the "dictionary" for the

Re: Speed up a slow loop

2022-03-08 Thread Quentin Long via use-livecode
sez Alex Tweedly:> The caveat - a user guess which isn't in the word list found by the > boardwalk can be either "not a word" or "a word, but not present on the  > board", and you don't know which. Does it *matter* whether a genuine word isn't on the board? If the board has no "L" in it, any

Re: Speed up a slow loop

2022-03-08 Thread J. Landman Gay via use-livecode
On 3/8/22 1:27 AM, Neville Smythe via use-livecode wrote: Jacque seems to have found a satisfactory solution to her problem with the help of the excellent suggestions we have seen here. Since there seems to have been a lot of interest, I thought I would take the opportunity to report on an

Re: Speed up a slow loop

2022-03-08 Thread J. Landman Gay via use-livecode
On 3/8/22 10:30 AM, Alex Tweedly via use-livecode wrote: I guess I'm not convinced about VM space thrashing being the problem, certainly not due to the wordlist. It's 2.5 Mb - i.e. 0.02% of the real RAM in a Pixel 5. There may be something else in the app making the total VM space very large -

Re: Speed up a slow loop

2022-03-08 Thread Alex Tweedly via use-livecode
On 08/03/2022 07:27, Neville Smythe via use-livecode wrote: I believe there were two problems: a) the original search search algorithm was too slow, and b) when implemented on certain devices the app went into an unusable state. Both problems were caused by the wordlist being stored being

Re: Speed up a slow loop

2022-03-08 Thread Mark Smith via use-livecode
Apart from searching I am sure it will provide many other great learning opportunities as well. Looking forward to seeing how it all pans out. Mark > On Mar 6, 2022, at 8:18 PM, J. Landman Gay via use-livecode > wrote: > > On 3/6/22 9:40 AM, William Prothero via use-livecode wrote: >> I've

Re: Speed up a slow loop

2022-03-07 Thread Neville Smythe via use-livecode
Jacque seems to have found a satisfactory solution to her problem with the help of the excellent suggestions we have seen here. Since there seems to have been a lot of interest, I thought I would take the opportunity to report on an alternative method I had been exploring with Jacque via email.

Re: Speed up a slow loop

2022-03-07 Thread J. Landman Gay via use-livecode
On 3/7/22 12:30 PM, Alex Tweedly via use-livecode wrote: The boardwalk will find all valid words on the board. So that list of words can be used as the "dictionary" for the user's guesses - and now you have a "dictionary" of only a few hundred words, rather than than the many thousands of

Re: Speed up a slow loop

2022-03-07 Thread Alex Tweedly via use-livecode
On 06/03/2022 22:56, J. Landman Gay via use-livecode wrote: 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,

Re: Speed up a slow loop

2022-03-06 Thread Bob Sneidar via use-livecode
You people are too smart for me. Sent from my iPhone > On Mar 6, 2022, at 07:41, William Prothero via use-livecode > wrote: > > Folks: > I've been following this thread in wonder at the creative ways of optimizing > this word search. I hope that the code will be published somewhere,

Re: Speed up a slow loop

2022-03-06 Thread J. Landman Gay via use-livecode
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

Re: Speed up a slow loop

2022-03-06 Thread Dick Kriesel via use-livecode
> On Mar 2, 2022, at 1:57 PM, J. Landman Gay via use-livecode > wrote: > ... > repeat for each line l in pList -- pList is the user word list >if sDictFile[l] = true then put l & cr after tCheckedList >else put l & cr after tNonWords >wait 0 with messages -- prevent ANRs > end

Re: Speed up a slow loop

2022-03-06 Thread J. Landman Gay via use-livecode
On 3/6/22 9:40 AM, William Prothero via use-livecode wrote: I've been following this thread in wonder at the creative ways of optimizing this word search. I hope that the code will be published somewhere, available to all, with credits to the multiple idea authors. I can upload it to Sample

Re: Speed up a slow loop

2022-03-06 Thread J. Landman Gay via use-livecode
On 3/6/22 7:33 AM, Alex Tweedly via use-livecode wrote: Could you maybe post the code that you're using that takes 5ms ? It does a bit more than your test, and I only estimated the number of user words since I'd tried so many things. I just tested again and this list has 173 words. The

Re: Speed up a slow loop

2022-03-06 Thread Alex Tweedly via use-livecode
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

Re: Speed up a slow loop

2022-03-06 Thread William Prothero via use-livecode
Folks: I've been following this thread in wonder at the creative ways of optimizing this word search. I hope that the code will be published somewhere, available to all, with credits to the multiple idea authors. Kudos and congratulations to those who offered such creative and thoughtful

Re: Speed up a slow loop

2022-03-06 Thread Alex Tweedly via use-livecode
On 06/03/2022 06:35, J. Landman Gay via use-livecode wrote: Combined with Ken's suggestion to use "difference", looking up a list of about 50 words in the filtered dictionary reduces the time from 2-4 seconds to about 40 ms. It varies, depending on a lot of things, but it's fast enough that

Re: Speed up a slow loop

2022-03-05 Thread J. Landman Gay via use-livecode
On 3/5/22 8:36 PM, Quentin Long via use-livecode wrote: When you create a new board: -- Make a list of all the letters which *are not* on the board -- Filter out any word that contains at least one letter on the "not on this board" list -- Use the thus-reduced wordlist for all purposes as

Re: Speed up a slow loop

2022-03-05 Thread J. Landman Gay via use-livecode
Interesting idea. There are 25 letters on each board, some are always repeats. I think I'd need a good regex so I wouldn't have to run the filter command multiple times. How's your regex? On the other hand, I suppose filtering out even just 2 or 3 letters might make a dent. I'll try that

Re: Speed up a slow loop

2022-03-05 Thread Quentin Long via use-livecode
So… a Boggle game. Hm. Seems to me that anything you can do to reduce the number of words you need consider at any given time would be a win. Maybe not a *big* win, but still a win. So perhaps give this idea a shot: When you create a new board: -- Make a list of all the letters which *are

Re: Speed up a slow loop

2022-03-04 Thread Bob Sneidar via use-livecode
Well… the idea was, if storing and working with the data as arrays was crucial, then I have a method for creating sqLite databases, memory or otherwise, from arrays and then back again. I don’t know if mobile devices can use memory databases, or perhaps the data is too much for mobile device

Re: Speed up a slow loop

2022-03-04 Thread J. Landman Gay via use-livecode
On 3/4/22 2:33 PM, Neville Smythe via use-livecode wrote: Jacque, are you trying to keep the whole of SOWPODS in memory the whole time? That’s a 2.5MB file. It sounds to me like you are getting virtual memory thrashing. I'm thinking the same thing, it's the only explanation. I stopped using

Re: Speed up a slow loop

2022-03-04 Thread Neville Smythe via use-livecode
Bob’s suggestion of storing the word list in an sqlite database would keep the list on disk and not in memory, so avoiding VM swapping which is I think the basic problem, and also use a much faster search engine than LC to do the checking for the existence of user candidates. A more elegant

Re: Speed up a slow loop

2022-03-04 Thread Neville Smythe via use-livecode
Jacque, are you trying to keep the whole of SOWPODS in memory the whole time? That’s a 2.5MB file. It sounds to me like you are getting virtual memory thrashing. If so, try breaking up the wordlist into 26 files for example - or even more by length as well as initial letter - kept as resources

Re: Speed up a slow loop

2022-03-03 Thread Bob Sneidar via use-livecode
I am not sure if Android or MacOS can use sqLite memory databases, but when I need to iterate through a large array, I first convert the array to an sqLite memory database, then query it, which is a gazillion times faster than iterating through an array. I have functions which create an

Re: Speed up a slow loop

2022-03-03 Thread Ken Ray via use-livecode
BTW you an also use this "split" trick to remove dupes (although you lose the order of the word list): function stripDupes pWordList split pWordList by cr and tab return (the keys of pWordList) end stripDupes on mouseUp put stripDupes("test" & cr & "ball" & cr & "test" & cr & "orange")

Re: Speed up a slow loop

2022-03-03 Thread Ken Ray via use-livecode
Jacque, How about using the 'difference' command? Here's a simple example: on mouseUp put "true" into tDict["test"] put "true" into tDict["word"] put "true" into tDict["ball"] put "test" & cr & "ball" & cr & "boat" & cr & "unicorn" into tUserWords split tUserWords by cr and

Re: Speed up a slow loop

2022-03-03 Thread J. Landman Gay via use-livecode
On 3/3/22 2:00 PM, Tom Glod via use-livecode wrote: But what prevents you from loading all your data into an array? and just iterating over the keys or index of an array? vs the lines of a long list.? That will yield the fastest performance. Right, it's an array, and I don't iterate. I just

Re: Speed up a slow loop

2022-03-03 Thread J. Landman Gay via use-livecode
On 3/3/22 12:53 AM, Mark Waddingham via use-livecode wrote: If the difference between `the milliseconds` before the loop, and then after is 0 or 1 millisecond - then that is how long it is taking. This means the issue is somewhere else. Are you sure there isn't anything you are doing either

Re: Speed up a slow loop

2022-03-03 Thread Tom Glod via use-livecode
This is a long thread and I can't read it at the moement,, and maybe you have answered this. But what prevents you from loading all your data into an array? and just iterating over the keys or index of an array? vs the lines of a long list.? That will yield the fastest performance. I should

Re: Speed up a slow loop

2022-03-03 Thread Pi Digital via use-livecode
I usually test this by using put the milliseconds into tMs …loop code… put the milliseconds - tMs This shows me a record of how long that loop took and helps me narrow down where the slow downs are occurring. You can do it within the loop too and keep a record for each iteration and see if it

Re: Speed up a slow loop

2022-03-02 Thread Mark Waddingham via use-livecode
On 2022-03-02 21:57, J. Landman Gay via use-livecode wrote: The loop takes forever. Here it is (sDictFile is a script local): repeat for each line l in pList -- pList is the user word list if sDictFile[l] = true then put l & cr after tCheckedList else put l & cr after tNonWords

Re: Speed up a slow loop

2022-03-02 Thread J. Landman Gay via use-livecode
On 3/2/22 11:41 PM, Richard Gaskin via use-livecode wrote: Jacque wrote: > so I'm not really looping through the keys, just looking for > a matching one. The loop is for each user word I need to find. > If there's no key, then the word isn't legal. What is the ratio of keys whose values are

Re: Speed up a slow loop

2022-03-02 Thread J. Landman Gay via use-livecode
On 3/2/22 8:14 PM, Rick Harrison via use-livecode wrote: That sounds like a memory leak! I was thinking the same thing, but you'd think it would leak on my old tablet too, the one with far less memory. -- Jacqueline Landman Gay | jac...@hyperactivesw.com HyperActive Software

Re: Speed up a slow loop

2022-03-02 Thread Richard Gaskin via use-livecode
Jacque wrote: > so I'm not really looping through the keys, just looking for > a matching one. The loop is for each user word I need to find. > If there's no key, then the word isn't legal. What is the ratio of keys whose values are "true" and those which are "false"? And what is the ratio

Re: Speed up a slow loop

2022-03-02 Thread Jerry Jensen via use-livecode
I did not know about filter! I think I am cured of my “among” disease. .Jerry > On Mar 2, 2022, at 7:29 PM, Ralph DiMola via use-livecode > wrote: > > I ran into this when doing mobile predictive typing for US cities(40,000) > with a scrollable dropdown of results. I did with a loop in

RE: Speed up a slow loop

2022-03-02 Thread Ralph DiMola via use-livecode
nfo.net -Original Message- From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On Behalf Of J. Landman Gay via use-livecode Sent: Wednesday, March 02, 2022 4:58 PM To: LiveCode Mailing List Cc: J. Landman Gay Subject: Speed up a slow loop In my Boggle game I have an arr

Re: Speed up a slow loop

2022-03-02 Thread Jerry Jensen via use-livecode
That does make sense and now I understand the problem. > On Mar 2, 2022, at 6:19 PM, J. Landman Gay via use-livecode > wrote: > > Actually, this is what I do: > > if sDictFile[L] = true then... > > which I thought would be pretty fast since it's accessing the array directly. > The array

Re: Speed up a slow loop

2022-03-02 Thread J. Landman Gay via use-livecode
On 3/2/22 6:40 PM, Phil Davis via use-livecode wrote: Did it ever work as expected, or has it always behaved this way on all devices? (If it ever did work right, I guess that points to a change that happened outside your code.) I'm trying to remember. I've mostly been testing on my tablet

Re: Speed up a slow loop

2022-03-02 Thread J. Landman Gay via use-livecode
On 3/2/22 7:44 PM, Jerry Jensen via use-livecode wrote: Instead of putting the keys into tCorrWdList and using “among the lines of tCorrWdList", how about using “among the keys of tCorrWdList”? Judging from no knowledge of the internals but guessing what it must do: “among the lines” has to

Re: Speed up a slow loop

2022-03-02 Thread Rick Harrison via use-livecode
It could also be the garbage collection cycle isn’t working right. > On Mar 2, 2022, at 7:52 PM, J. Landman Gay via use-livecode > wrote: > > I noticed today though that there's a more general slowdown overall. When I > first launch the app it takes only a second to set up the board display.

Re: Speed up a slow loop

2022-03-02 Thread Rick Harrison via use-livecode
That sounds like a memory leak! > On Mar 2, 2022, at 7:52 PM, J. Landman Gay via use-livecode > wrote: > > I noticed today though that there's a more general slowdown overall. When I > first launch the app it takes only a second to set up the board display. If I > keep hitting the "new

Re: Speed up a slow loop

2022-03-02 Thread Rick Harrison via use-livecode
A few years ago I found that 0.1 milliseconds was faster for some crazy reason. Maybe that bug finally got fixed? > On Mar 2, 2022, at 7:40 PM, J. Landman Gay via use-livecode > wrote: > > It gets slower. :( ___ use-livecode mailing list

Re: Speed up a slow loop

2022-03-02 Thread Jerry Jensen via use-livecode
Arrgh. Try again. “among the keys of C” instead of the keys of tCorrWdList like I wrote. I’ll quit now. .Jerry > On Mar 2, 2022, at 5:44 PM, Jerry Jensen via use-livecode > wrote: > > Now that I’m thinking more directly, I’ll try again: > > Instead of putting the keys OF C into tCorrWdList

Re: Speed up a slow loop

2022-03-02 Thread Jerry Jensen via use-livecode
Now that I’m thinking more directly, I’ll try again: Instead of putting the keys into tCorrWdList and using “among the lines of tCorrWdList", how about using “among the keys of tCorrWdList”? Judging from no knowledge of the internals but guessing what it must do: “among the lines” has to look

Re: Speed up a slow loop

2022-03-02 Thread J. Landman Gay via use-livecode
On 3/2/22 6:32 PM, Rick Harrison via use-livecode wrote: Eon’s ago I had a similar problem in Fortran. My solution was to break up my huge array into 3 smaller alphabetical arrays. I had to first determine with some if statements which of the 3 arrays I had to search. The solution turned a

Re: Speed up a slow loop

2022-03-02 Thread Phil Davis via use-livecode
Jacque - Did it ever work as expected, or has it always behaved this way on all devices? (If it ever did work right, I guess that points to a change that happened outside your code.) Phil Davis On 3/2/22 4:35 PM, J. Landman Gay via use-livecode wrote: On 3/2/22 5:12 PM, Devin Asay via

Re: Speed up a slow loop

2022-03-02 Thread J. Landman Gay via use-livecode
On 3/2/22 5:06 PM, Rick Harrison via use-livecode wrote: What happens if you wait longer than 0? It gets slower. :( -- Jacqueline Landman Gay | jac...@hyperactivesw.com HyperActive Software | http://www.hyperactivesw.com

Re: Speed up a slow loop

2022-03-02 Thread J. Landman Gay via use-livecode
On 3/2/22 6:19 PM, Jerry Jensen via use-livecode wrote: Could using “is among the keys of sDictFile” instead of the loop be another advantage? I need to loop through all the user words, checking each one against the dictionary. I.e. the loop is going through a short list of user entries, not

Re: Speed up a slow loop

2022-03-02 Thread J. Landman Gay via use-livecode
On 3/2/22 5:12 PM, Devin Asay via use-livecode wrote: Have you tried put the keys of sDictFile into tCorrWdList repeat for each line I in pList if I is among the lines of tCorrWdList then put I & cr after tCheckedList else put I & cr after tNonWords end if end repeat

Re: Speed up a slow loop

2022-03-02 Thread Rick Harrison via use-livecode
Eon’s ago I had a similar problem in Fortran. My solution was to break up my huge array into 3 smaller alphabetical arrays. I had to first determine with some if statements which of the 3 arrays I had to search. The solution turned a glacially slow search into a very acceptable one. You may

Re: Speed up a slow loop

2022-03-02 Thread Jerry Jensen via use-livecode
Could using “is among the keys of sDictFile” instead of the loop be another advantage? .Jerry > On Mar 2, 2022, at 3:12 PM, Devin Asay via use-livecode > wrote: > > Jacque, > > Have you tried > > put the keys of sDictFile into tCorrWdList > repeat for each line I in pList > if I is among

Re: Speed up a slow loop

2022-03-02 Thread Devin Asay via use-livecode
Jacque, Have you tried put the keys of sDictFile into tCorrWdList repeat for each line I in pList if I is among the lines of tCorrWdList then put I & cr after tCheckedList else put I & cr after tNonWords end if end repeat I just wonder if there is some overhead with

Re: Speed up a slow loop

2022-03-02 Thread Rick Harrison via use-livecode
What happens if you wait longer than 0? Rick > On Mar 2, 2022, at 4:57 PM, J. Landman Gay via use-livecode > wrote: > > In my Boggle game I have an array containing dictionary words as keys, split > as set, so all values are "true". I need to compare those keys with a list of > user words

Speed up a slow loop

2022-03-02 Thread J. Landman Gay via use-livecode
In my Boggle game I have an array containing dictionary words as keys, split as set, so all values are "true". I need to compare those keys with a list of user words and get back a list of good words and a list of illegal words. The loop takes forever. Here it is (sDictFile is a script local):