Searching through text - Speed issue
I was searching a list of 100 key words in a 1 million line text file. I used
two methods of looping the search:
1. I loop through all lines in the text file for each key word
2. I loop through all key words for each line in the text file
Both ways search through 100 times 1 million lines. How come after many
tests, the second method is about 30% faster than the first?
|