AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Fastest way to search a big list

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Tekl



Joined: 24 Sep 2004
Posts: 813
Location: Germany

PostPosted: Mon Mar 07, 2005 2:24 am    Post subject: Fastest way to search a big list Reply with quote

Hello,

has anyone checked the performance of different ways how to search through a big wordlist?

I think there are three ways:

1. The list is in a variable with delimiters and searched with a ParseLoop
2. The list is in a file and searched with a FileLoop
3. The list is stored in an array and is searched with a normal Loop

Which way is the fastest or are there different ways?

Tekl
Back to top
View user's profile Send private message Visit poster's website
jonny



Joined: 13 Nov 2004
Posts: 3004
Location: Minnesota

PostPosted: Mon Mar 07, 2005 2:29 am    Post subject: Reply with quote

Technically, the fastest way would be to store it in AHK itself, in a hypothetical array using variable initializations. Then, just use a regular loop with a_index.
Back to top
View user's profile Send private message
Guest






PostPosted: Mon Mar 07, 2005 1:25 pm    Post subject: Reply with quote

I have a large CSV file that I read with FileRead and parse with IfInString and StringGetPos. It takes a little more effort if there are multiple instances of this string. The best thing is to set up a trial run and see what works for you. Remeber to set SetBatchLines to -1.
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Mon Mar 07, 2005 1:30 pm    Post subject: Reply with quote

Because uncached files are very slow to read from, avoiding disk access where possible should speed up the operation.

When storing data in memory rather than on disk, I suspect a parsing loop would be faster than arrays, especially if the number of fields/items is very large.
Back to top
View user's profile Send private message Send e-mail
Tekl



Joined: 24 Sep 2004
Posts: 813
Location: Germany

PostPosted: Tue Mar 08, 2005 1:52 pm    Post subject: Reply with quote

Hi,

now I mixed up Arrays and single Variables. Because I want to search for starting letters I created Arrays with the starting letters in the name.

Var_Ab contains all Words starting with Ab like: abuse, abort ...
Var_Co contains all Words starting with Co like: cold, common ...

so I don't have to search one big variable. It's significant faster than the other ways I tried. Only creating the arrays is slower for the first time.

Thanks for the hints.

To use StringGetPos I need an enhancement of this command, so that I can specify form wich position the search will start.

StringGetPos, OutputVar, InputVar, SearchText [, L#|R#, startPos]

Tekl
Back to top
View user's profile Send private message Visit poster's website
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Wed Mar 09, 2005 3:23 am    Post subject: Reply with quote

Tekl wrote:
To use StringGetPos I need an enhancement of this command, so that I can specify form wich position the search will start.

StringGetPos, OutputVar, InputVar, SearchText [, L#|R#, startPos]
Sounds like a good improvement. Since it seems an easy change it should get done soon.

Until then, you probably already know you can use StringTrimRight to omit the beginning of a string, though of course that requires another variable and would perform worse.

Edit: This change has been applied to v1.0.30.03. Please let me know if you find any problems with it.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group