I did not compare protocol buffers with native Java serialization in terms of speed, but for the interoperability of native serialization, Java is a serious no-no. In most cases, it will also not be as space-efficient as protocol buffers. Of course, it is somewhat more flexible in terms of what it can store, and in terms of links, etc. Protocol buffers are very good at what it is designed for, and when it meets your needs, this is great - but there are obvious limitations due to compatibility (and other things).
I recently published the base buffer protocol framework in Java and .NET. The Java version is in the main Google project (in the benchmarks directory), the .NET version is in my C # port project . If you want to compare PB speed with Java serialization speed, you can write similar classes and compare them. If you are interested in interop, though, I really would not give a native Java serialization (or a native binary .NET serialization) a second thought.
There are other options for interoperable serialization, in addition to protocol buffers, although Thrift , JSON and YAML spring, and there are undoubtedly others.
EDIT: Well, if interop is not that important, it's worth trying to list the various qualities you want from the scope of serialization. One thing you should think about is version control - this is another thing that PB is designed to handle well, both backward and forward (so that new software can read old data and vice versa) - when you stick to the suggested rules , sure:)
Trying to be careful about Java performance versus native serialization, I really wonβt be surprised that PB will still be faster. If you have such an opportunity, use the vm server - my recent tests showed that the server VM should be twice as fast when serializing and deserializing sample data. I think PB code is suitable for VM JIT server very nicely :)
As an example of performance indicators, serialization and deserialization of two messages (one 228 bytes, one 84,750 bytes), I got these results on my laptop using a VM server:
Benchmarking benchmarks.GoogleSize $ SizeMessage1 with file google_message1.dat
Serialize to byte string: 2581851 iterations in 30.16s; 18.613789MB / s
Serialize to byte array: 2583547 iterations in 29.842s; 18.824497MB / s
Serialize to memory stream: 2210320 iterations in 30.125s; 15.953759MB / s
Deserialize from byte string: 3356517 iterations in 30.088s; 24.256632MB / s
Deserialize from byte array: 3356517 iterations in 29.958s; 24.361889MB / s
Deserialize from memory stream: 2618821 iterations in 29.821s; 09/19/4952MB / s
Benchmarking benchmarks.GoogleSpeed ββ$ SpeedMessage1 with file google_message1.dat
Serialize to byte string: 17068518 iterations in 29.978s; 123.802124MB / s
Serialize to byte array: 17520066 iterations in 30.043s; 126.802376MB / s
Serialize to memory stream: 7736665 iterations in 30.076s; 55.93307MB / s
Deserialize from byte string: 16123669 iterations in 30.073s; 116.57947MB / s
Deserialize from byte array: 16082453 iterations in 30.109s; 116.14243MB / s
Deserialize from memory stream: 7496968 iterations in 30.03s; 54.283176MB / s
Benchmarking benchmarks.GoogleSize $ SizeMessage2 with file google_message2.dat
Serialize to byte string: 6266 iterations in 30.034s; 16.826494MB / s
Serialize to byte array: 6246 iterations in 30.027s; 16.776697MB / s
Serialize to memory stream: 6042 iterations in 29.916s; 16.288969MB / s
Deserialize from byte string: 4675 iterations in 29.819s; 12.644595MB / s
Deserialize from byte array: 4694 iterations in 30.093s; 12.580387MB / s
Deserialize from memory stream: 4544 iterations in 29.579s; 12.389998MB / s
Benchmarking benchmarks.GoogleSpeed ββ$ SpeedMessage2 with file google_message2.dat
Serialize to byte string: 39562 iterations in 30.055s; 106.16416MB / s
Serialize to byte array: 39715 iterations in 30.178s; 106.14035MB / s
Serialize to memory stream: 34161 iterations in 30.032s; 91.74085MB / s
Deserialize from byte string: 36934 iterations in 29.794s; 99.98019MB / s
Deserialize from byte array: 37191 iterations in 29.915s; 100.26867MB / s
Deserialize from memory stream: 36237 iterations in 29.846s; 97.92251MB / s
βSpeedβ and βsizeβ are whether the generated code is optimized for speed or code size. (Serialized data is the same in both cases. The "size" version is provided for the case when you have defined many messages and do not want to receive a lot of memory for the code.)
As you can see, for a smaller message this can be very fast - over 500 small messages serialized or deserialized in a millisecond. Even with a 87K message, it takes less than a millisecond for a message.