Re: StreamReader.ReadToEnd
- From: Lasse Vågsæther Karlsen <lasse@xxxxxxxxxxx>
- Date: Tue, 7 Mar 2006 15:51:54 +0000 (UTC)
And in terms of speed, is StreamReader.ReadToEnd() or reading byte by
byte yourself (and handling the buffering yourself) faster?
Unless Microsoft did a really botched up job of implementing ReadToEnd I'd say that by default the implementation of ReadToEnd will be faster than reading byte by byte.
However, if your goal is to read the rest of the file and process it then it depends:
with your buffering solution, would you:
- fill the buffer, process it, then throw it away or reuse it?
- fill the buffer, then keep it and allocate a new buffer for the rest?
the difference would be if you were to process a really big file, larger than your amount of available memory. With .ReadToEnd, you might end up swapping memory blocks to disk, which is costly. If you process the file a buffer at a time, you might not need to as the size of the file would be irrelevant as you only keep a buffers worth in memory anyway.
--
Lasse Vågsæther Karlsen
http://usinglvkblog.blogspot.com/
mailto:lasse@xxxxxxxxxxx
PGP KeyID: 0x2A42A1C2
.
- Follow-Ups:
- Re: StreamReader.ReadToEnd
- From: Chris S.
- Re: StreamReader.ReadToEnd
- References:
- Re: StreamReader.ReadToEnd
- From: Chris S.
- Re: StreamReader.ReadToEnd
- Prev by Date: Re: C# Threading, and suspending or killing a thread
- Next by Date: Re: Embed a windows application in a browser
- Previous by thread: Re: StreamReader.ReadToEnd
- Next by thread: Re: StreamReader.ReadToEnd
- Index(es):
Relevant Pages
|