Optimization can be tricky

Alex Tweedly alex at tweedly.net
Tue Jun 12 16:54:05 EDT 2018

Then there's something about Geoff's problem (or problem statement) that 
I don't understand.

What on earth is in those records for sorting a mere 2000 of them to be 
noticable? (I had thought he had to be talking about magnitudes more 
lines than that).

LC (9.0) sorts 20,000 lines of >1000 chars each in 65ms or so, on my 
aging MacBook Pro. So the delay can't be the sort - it must be in the 
extracting of the data from the arrays into his 'candidateList'.

It would be good to get that clarified before we spend more time 
optimizing the wrong thing :-)


On 12/06/2018 21:39, hh via use-livecode wrote:
> The scenario Geoff described is roughly to get the
> top ten (a handful) of 2000 records comparing a certain
> numeric value of each.
> To get that unknown value of each one has to go once through
> all the records *and then sort* for that ranking.
> (LiveCode is very fast with a simple numeric sort!)
> Any other method of ranking while going through the data
> will generously waste CPU time.
>> Curry wrote:
>> Put yourself in the computer's shoes, and also clarify what you need to
>> accomplish. You are asking it to sort the entire list of 2000 records,
>> but (if I understand) you only want a handful of those.
>> And it has already gone through all the records once before the sort. If
>> you asked a human to do that, it would be a risky interaction. There
>> might be raised voices when they present the neatly arranged file
>> cabinet with files in a special order, and you deliver the punch line
>> that you only need to pull a few. If you only need to pull 5 records,
>> most people don't want to go through all 2000 files - twice.
>> So generally, don't use a sort after doing a complete loop on a big text
>> list, use another method. Do unto your computer as you hope it will do
>> unto you when they run the world. :)
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

More information about the use-livecode mailing list