Fast save and load basic data types?

K

Kevin

Hello all:

I am just wondering whether there is any reference/comparison of how to
save and load java's data types fast, into/from disk files?

For example, what class/method to use if I want to save 10 million
integer and/or double and/or String into a file in order, and later to
read them back in that order?

Current, I use ObjectOutputStream over buffered file, and use writeInt,
writeDouble, writeUTF for this purpose.

I tested that on my WinXP computer, writing 10 million double needs
about 6 seconds, resulting in a file of 76M, and reading them back
needs 4 seconds. Since I have no comparsion, so I suppose this is the
fastest speed I can get, right?

Thanks a lot and have a nice weekend!

Kevin
PS: I mean to use the supplied classes from standard Sun Java only ----
I do not want to create any very complicated "smart" classes that lose
generality.
 
W

Wibble

Kevin said:
Hello all:

I am just wondering whether there is any reference/comparison of how to
save and load java's data types fast, into/from disk files?

For example, what class/method to use if I want to save 10 million
integer and/or double and/or String into a file in order, and later to
read them back in that order?

Current, I use ObjectOutputStream over buffered file, and use writeInt,
writeDouble, writeUTF for this purpose.

I tested that on my WinXP computer, writing 10 million double needs
about 6 seconds, resulting in a file of 76M, and reading them back
needs 4 seconds. Since I have no comparsion, so I suppose this is the
fastest speed I can get, right?

Thanks a lot and have a nice weekend!

Kevin
PS: I mean to use the supplied classes from standard Sun Java only ----
I do not want to create any very complicated "smart" classes that lose
generality.
If thats fast enough, your done. Why waste time asking?

If its not, then you'll get better performance by preallocating a byte
array, packing it, and calling OutputStream.write(). Class like
ObjectOutputStream are smart classes. Performance usually requires
dumb classes and smart algorithms.
 

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

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top