Re: IO with Java Objects: slow!
From: Collin VanDyck (thehoppocket_at_yahoo.com)
Date: 03/02/04
- Next message: Lee Fesperman: "Re: Can I use a class from another folder?"
- Previous message: Andrew Thompson: "Re: Modifying read only files in Java"
- In reply to: Charles Packer: "IO with Java Objects: slow!"
- Next in thread: nos: "Re: IO with Java Objects: slow!"
- Reply: nos: "Re: IO with Java Objects: slow!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 02 Mar 2004 22:52:19 GMT
"Charles Packer" <mailbox@cpacker.org> wrote in message
news:f88bc493.0403021441.1013f167@posting.google.com...
> I have a Vector of 120,000 Vectors, each of which is about 60 bytes long.
> Writing it out to the disk in an ObjectOutputStream as a single Object
> takes 20 seconds on our system, as does writing out the 120K Vectors
> individually as Objects. But if I change each Vector into a byte array and
> write them to the disk in a BufferedOutputStream, it takes only 6 seconds
> when I write them as individual byte arrays. If I build a byte buffer of
> the whole dataset first, writing it takes less than one second.
>
> The implication is that where speed of file access is critical, it's
better
> to bypass the convenience of dealing with Objects and use plain vanilla
> formats, the tradeoff being some extra parsing.
Yes, you'll definitely find a tradeoff between Arrays (which are Objects
too!) and the Collections classes. Note though that you chose a
slow-by-nature Collection -- the Vector. See what your time is using an
ArrayList, which is faster.
-CV
- Next message: Lee Fesperman: "Re: Can I use a class from another folder?"
- Previous message: Andrew Thompson: "Re: Modifying read only files in Java"
- In reply to: Charles Packer: "IO with Java Objects: slow!"
- Next in thread: nos: "Re: IO with Java Objects: slow!"
- Reply: nos: "Re: IO with Java Objects: slow!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|