Byte Stream Vs Char Stream Buffer

S

Silvio

UTF-16 ends up reading twice as many bytes. However the magic 50%
ratio is still optimal.


Using a random sample data file of 209,715,200 chars 419,430,402
bytes.
Using aggregate buffersize of 65,536 bytes.
Using charset UTF-16
end read using HunkIO 2.65 seconds
end read using using BufferedReader backed with BufferedInputStream
ratio 0.10 buffsize 65536 bytes 2.70 seconds
end read using using BufferedReader backed with BufferedInputStream
ratio 0.20 buffsize 65536 bytes 2.68 seconds
end read using using BufferedReader backed with BufferedInputStream
ratio 0.30 buffsize 65536 bytes 2.67 seconds
end read using using BufferedReader backed with BufferedInputStream
ratio 0.40 buffsize 65536 bytes 2.68 seconds
end read using using BufferedReader backed with BufferedInputStream
ratio 0.50 buffsize 65536 bytes 2.61 seconds <<<
end read using using BufferedReader backed with BufferedInputStream
ratio 0.60 buffsize 65536 bytes 2.72 seconds
end read using using BufferedReader backed with BufferedInputStream
ratio 0.70 buffsize 65536 bytes 2.73 seconds
end read using using BufferedReader backed with BufferedInputStream
ratio 0.80 buffsize 65536 bytes 2.78 seconds
end read using using BufferedReader backed with BufferedInputStream
ratio 0.90 buffsize 65536 bytes 2.72 seconds

Thank you Roedy. Interesting results. Kind of surprising as well.

Cheers,

Silvio
 
Joined
Nov 20, 2014
Messages
2
Reaction score
0
A byte stream access the file byte by byte. Java programs use byte streams to perform input and output of 8-bit bytes. It is suitable for any kind of file, however not quite appropriate for text files. For example, if the file is using a unicode encoding and a character is represented with two bytes, the byte stream will treat these separately and you will need to do the conversion yourself.

A character stream will read a file character by character. Character Stream is a higher level concept than Byte Stream . A Character Stream is, effectively, a Byte Stream that has been wrapped with logic that allows it to output characters from a specific encoding .

Crony
 
Last edited by a moderator:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,091
Messages
2,570,605
Members
47,225
Latest member
DarrinWhit

Latest Threads

Top