which is faster for searching?

Peter Haworth pete at lcsql.com
Tue Jun 17 16:18:30 EDT 2014


I just did a very simple test comparing repeat with filter.

I put 500,000 lines of 6 random chars into a variable then used a repeat
for loop to check for a 3 character string in each line and append the line
to another variable, plus a filter statement to do the same thing.

The repeat loop took 153 ms and the filter took 38ms.  Neither time is
particularly significant but impressive that filter is faster than a repeat
loop by a factor of around 4.  I did find that the times got closer when I
increased the number of chars in each line and the length of the search
string but filter was still twice as fast as repeat.

Pete
lcSQL Software <http://www.lcsql.com>
Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>


On Tue, Jun 17, 2014 at 11:17 AM, <larry at significantplanet.org> wrote:

> Thanks Pete,
> Which version exactly is it?
> Larry
>
> ----- Original Message ----- From: "Peter Haworth" <pete at lcsql.com>
> To: "How to use LiveCode" <use-livecode at lists.runrev.com>
> Sent: Tuesday, June 17, 2014 11:25 AM
> Subject: Re: which is faster for searching?
>
>
>  You might want to try the filter command too, especially the new version
>> that has a lot more options including the ability to put the qualifying
>> lines into a different container.
>>
>> Pete
>> lcSQL Software <http://www.lcsql.com>
>> Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
>> SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>
>>
>>
>> On Tue, Jun 17, 2014 at 7:22 AM, <larry at significantplanet.org> wrote:
>>
>>  I have a large variable containing about 3000 lines of data - each line
>>> about 100 characters.
>>>
>>> I want to search through the variable and find all the lines that contain
>>> a specified string
>>>
>>> Should I use (repeatedly) "lineoffset...", or should I use "repeat for
>>> each line..."  or maybe some other faster way?
>>>
>>> Or with only 3000 lines of data, does it even matter?
>>>
>>> TIA
>>> Larry
>>> _______________________________________________
>>> 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
>>>
>>>  _______________________________________________
>> 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
>>
>
>
> _______________________________________________
> 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