commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@btopenworld.com>
Subject Re: [lang] Performance enhancement for SerializationUtils
Date Sun, 22 Dec 2002 20:00:32 GMT
Thanks for this advice, I've included it in the CVS.

(I've added specific comments for the stream methods about buffering)

Stephen

----- Original Message -----
From: "Jeff Varszegi" <jvarszegi@yahoo.com>
> Here is the code for the serialize(Serializable) method:
>
>     public static byte[] serialize(Serializable obj) {
>         ByteArrayOutputStream baos = new ByteArrayOutputStream();
>         serialize(obj, baos);
>         return baos.toByteArray();
>     }
>
> This can be sped up a significant amount just by using a different
constructor for the
> ByteArrayInputStream instance, passing in a number higher than 32, so it
constructs a bigger
> initial buffer than it otherwise would.  Bumping up the initial buffer
size to 128 worked about as
> well as bumping it up to 512 on my machine.
>
> This alone resulted in an overall 6% speed increase for the
clone(Serializable) method on my
> machine.
>
> For the methods serialize(Serializable, OutputStream) and
deserialize(InputStream) it may be
> desirable to wrap the passed streams in buffered streams.  Serialization
to/from streams is
> typically done for persistence, passing objects between JVMs, etc. and
it's not hard to imagine
> someone passing in unbuffered streams in these situations...
>
> Jeff
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Web Hosting - Let the expert host your site
> http://webhosting.yahoo.com
>
> --
> To unsubscribe, e-mail:
<mailto:commons-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:commons-dev-help@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message