Optimization can be tricky

Curry Kenworthy curry at pair.com
Tue Jun 12 19:00:43 EDT 2018


Optimizing scripts in LC is not the same as running reports in other 
software suites. If you only need 10 results, you probably don't want to 
handle all items twice.

I hate to loop through all items even once. But if I do, I may be done! 
I'm not making a full report to print out; I'm just getting my 10 items. 
If I use sort or filter, likewise, I will do whatever necessary to keep 
it short and sweet, even if that means adjusting some of the starting 
assumptions.

If the sort really is taking more time than the loop, something is 
bogging it down. Look at the random() and arithmetic attached to the 
sort. That's potentially like running a whole lot of LCS. So if you 
sort, try a plain numeric sort with no fancy stuff added. Then go grab 
your 10 - the other requirements can be addressed before or after the sort.

Best wishes,

Curry Kenworthy

Custom Software Development
LiveCode Training and Consulting
http://livecodeconsulting.com/




More information about the Use-livecode mailing list