473,320 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

FileStream Speed issue

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
2 1810
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: James Johnson | last post by:
I have a file that I open a FileStream and a StreamReader for. I issue a SEEK and read a series of records. I then issue another SEEK, no errors, but when I issue the read it picks up where the...
0
by: James Johnson | last post by:
I have a file that I open a FileStream and a StreamReader for. I issue a SEEK and read a series of records. I then issue another SEEK, no errors, but when I issue the read it picks up where the...
7
by: Nathan Sokalski | last post by:
I am having a problem saving an image with the same name it originally had. I have two similar versions of my code, one in which I close the FileStream used to open the original image before saving,...
7
by: Nathan Sokalski | last post by:
I am having a problem saving an image with the same name it originally had. I have two similar versions of my code, one in which I close the FileStream used to open the original image before saving,...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.