473,473 Members | 1,824 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Idea for Reader optimisation for reading

Hi,

I was using the Reader class to read a binary file and I noticed that
there is no PeekByte and also its not optimised when using Peek and Read in
sequence.

If the .Peek is called its read the next char, and then .Read after its
reading twice, why cant the .Read use the stored Peek internally? It would
be twice as fast.
Jul 21 '05 #1
2 1423
Hi,

Thanks for your post. As I understand, you have some performance concerns
about the Reader class. I'd like to share the following information with
you:

What's the Reader class you are using?

Generally speaking, the Peek method of Reader classes (say, StreamReader,
etc) will return the next available character. That is, it should be of the
same with the PeekByte you suggested.

In addition, please kindly note that the FileStream has buffering
internally to improve read and write performance. A buffer is a block of
bytes in memory used to cache data, thereby reducing the number of calls to
the operating system. A call to .Read after a .Peek call will get data from
the cache, so I believe there is no need to worry about the performance.

Please feel free to let me know if you have any problems or concerns.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #2
Tian Min Huang <ti******@online.microsoft.com> wrote:
Thanks for your post. As I understand, you have some performance concerns
about the Reader class. I'd like to share the following information with
you:

What's the Reader class you are using?

Generally speaking, the Peek method of Reader classes (say, StreamReader,
etc) will return the next available character. That is, it should be of the
same with the PeekByte you suggested.


Why would reading a character and reading a byte be the same thing?
Character data and binary data are entirely different kettles of fish.

Personally I don't believe there should be a PeekByte simply because
TextReaders are meant to read character data, not binary data.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Anand | last post by:
I just implemented a program to solve reader writter prob. Wenever I run the program it seems to go into S+ state and it waits there I dont know why. When i attach gdb to one of the childs and step...
5
by: Drew Yallop | last post by:
I read an XML file with a stream reader in VB.Net. When I look at the stream reader output in debug mode (by passing cursor over the stream reader object)the format is a perfect replica of the...
6
by: james | last post by:
I will try to make this short and to the point. I am reading values from a file using a Binary Reader. At a particular address I can get a value of , Hex 10 or Hex 01 . (varies can be 30, 20, 02,03...
2
by: | last post by:
Hi, I was using the Reader class to read a binary file and I noticed that there is no PeekByte and also its not optimised when using Peek and Read in sequence. If the .Peek is called its read...
6
by: Karl Seguin [MVP] | last post by:
The BinaryWriter/Reader's are little-endian only. Was hoping they were going to be made more flexible in 2.0, but that doesn't appear to be the case. Anyone already done all the work of...
1
by: grid | last post by:
Hi, I was exploring the affect of cache on program performance/optimisation.Is it the compilers responsibility only to consider this kind of optimisation or the programmer can do his bit in this...
6
by: dgleeson3 | last post by:
Hello All I have VB code (.Net 2005) reading from an SQL server 2005 database. Im getting InvalidCastException when doing reader.GetInt32(0) Im simply reading an int from a simple database. It...
3
by: Matt Nunnally | last post by:
I'm using XmlReader to read an XMl String such as this one: <XML_REQUEST> <USER_ID>Admin</USER_ID> <USER_PW>Test123%</USER_PW> <COMMAND>1</COMMAND> <PRESENT_FLAG>1</PRESENT_FLAG>...
0
tlhintoq
by: tlhintoq | last post by:
My project involves reading magstripe cards, capturing an ID number, then spinning off to do some other things including taking a photograph. 99% of this is done and good. All early phases of work...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.