sunnyhub / thrift-protobuf-compare

Automatically exported from code.google.com/p/thrift-protobuf-compare
0 stars 0 forks source link

Simplify and improve performance of ProtobufSerializer.serialize #2

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Patch says it all:

Index: src/serializers/ProtobufSerializer.java
===================================================================
--- src/serializers/ProtobufSerializer.java (revision 44)
+++ src/serializers/ProtobufSerializer.java (working copy)
@@ -19,8 +19,7 @@

     public byte[] serialize(MediaContent content, ByteArrayOutputStream
baos) throws IOException
     {
-        content.writeTo(baos);
-        return baos.toByteArray();
+      return content.toByteArray();
     }

   public MediaContent create()

Original issue reported on code.google.com by ismaelj on 25 Mar 2009 at 7:45

GoogleCodeExporter commented 8 years ago
By the way, I would regenerate the performance numbers after this change. As 
shown
here[1], it makes a substantial difference.

[1]
http://blog.juma.me.uk/2009/03/25/json-serializationdeserialization-faster-than-
protocol-buffers/

Original comment by ismaelj on 25 Mar 2009 at 7:49

GoogleCodeExporter commented 8 years ago

Original comment by eis...@gmail.com on 25 Mar 2009 at 8:01

GoogleCodeExporter commented 8 years ago
Fixed. Wanted to add a comment in your blog, but its not passing through.
In order to be fair to the other serializes I removed the stream management out 
of
the benchmarking.

Original comment by eis...@gmail.com on 26 Mar 2009 at 4:37

GoogleCodeExporter commented 8 years ago
Thanks, I approved the comments (not sure why wordpress thought they were 
spam). I'll
take a look at the changes once I get home.

Original comment by ismaelj on 26 Mar 2009 at 4:50