-
October 25th, 2012, 03:24 PM
#1
Parsing Text Files Asyncronously
Have an application that needs to read and analyse numerous text files. Each file will only be about the length of a chapter in a book. I am using StreamReader to load the text. Each text will be read in a separate thread.
Would it be faster to load each file to the end, then analyse; or load and analyse line by line?
-
October 27th, 2012, 09:27 AM
#2
Re: Parsing Text Files Asyncronously
Essentially, reading x number of bytes from a file will take the same amount of time whether you read them all up front or a little at a time. In my opinion, the consideration here is how long do you want to hold the resource (file) open. It is generally good practice to hold any resource open as little time as possible, so I'm thinking it would be best to open the file, read all of it into memory, then immediately close it. That way the file is not held open during the analysis process. you may want to also consider how much memory you have available. If you have 2 gig of memory and are trying to process 3 gig of files, Windows will be forced to page memory (between the HDD and RAM) slowing down things considerably.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|