By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,795 Members | 1,199 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,795 IT Pros & Developers. It's quick & easy.

FileStream Speed issue

P: n/a
Yello,

Quick Q:
What is the fastest way of getting data from a file?
Does the though put of the file increase if I collect
a great big chunk of it? Eg say 6meg? or does that
even help?

Does a bufferedstream work better if I am just going
to open a file and read it?

All I am doing, is opening the file stream,
collecting enough data for a "packet" of data,
parcing it, then going for another packet.
I though maybe if I collect a chunk of memory
from the HD, the speed may improve?

Thanks in advance.
Jan 26 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
TheMadHatter,

This is one of those things where you have to fine tune your code in
response to regular conditions.

I don't think a bufferedstream will work here because getting the bytes
is going to be a quick operation.

What you have to remember is that while you might decrease the number of
file operations by reading larger chunks from the file system, you have to
weigh that against the cost of memory allocation, which in large chunks, can
be more detrimental than the hit you would take reading from the file
system.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"TheMadHatter" <Th**********@discussions.microsoft.com> wrote in message
news:1A**********************************@microsof t.com...
Yello,

Quick Q:
What is the fastest way of getting data from a file?
Does the though put of the file increase if I collect
a great big chunk of it? Eg say 6meg? or does that
even help?

Does a bufferedstream work better if I am just going
to open a file and read it?

All I am doing, is opening the file stream,
collecting enough data for a "packet" of data,
parcing it, then going for another packet.
I though maybe if I collect a chunk of memory
from the HD, the speed may improve?

Thanks in advance.

Jan 26 '06 #2

P: n/a
TheMadHatter <Th**********@discussions.microsoft.com> wrote:
Quick Q:
What is the fastest way of getting data from a file?
Does the though put of the file increase if I collect
a great big chunk of it? Eg say 6meg? or does that
even help?


In my experience it helps a very small amount (and only in some tests).
I would suggest a buffer size of about 16 or 32K usually. That way it's
definitely not on the large object heap, but can store a fair chunk of
data.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 26 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.