| View previous topic :: View next topic |
| Author |
Message |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Mon Mar 07, 2005 2:24 am Post subject: Fastest way to search a big list |
|
|
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 |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3004 Location: Minnesota
|
Posted: Mon Mar 07, 2005 2:29 am Post subject: |
|
|
| 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 |
|
 |
Guest
|
Posted: Mon Mar 07, 2005 1:25 pm Post subject: |
|
|
| 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
|
Posted: Mon Mar 07, 2005 1:30 pm Post subject: |
|
|
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 |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Tue Mar 08, 2005 1:52 pm Post subject: |
|
|
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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Wed Mar 09, 2005 3:23 am Post subject: |
|
|
| 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 |
|
 |
|