I'm looking to get sense if my experience sounds reasonable or if it sounds like I'm doing something very wrong, any insight appreciated!
I have a Serializable Java object containing: 4 integers 3 bytes 2 Strings 1 short 1 double I have a vector of about 10M objects I am sending from a server to a client. The ObjectOutputStream for the server is created like this: Socket clientSocket; ... outputStream = new ObjectOutputStream(clientSocket.getOutputStream()); and the ObjectInputStream is created in a similar fashion. I send the Serializable objects like this: outputStream.writeObject(msg); and receive them like this: MyMessage msg = (MyMessage)inputStream.readObject(); On my rather slow server I can receive and process about 12K messages a second. Now for the Protocol Buffers part: I used protoc to create a new Java class using: 8 int32s 2 strings 1 double I create objects like this: MyProtoMessage.MyMessage msg = MyProtoMessage.MyMessage.newBuilder() ... .build(); and send them like this: byte size = (byte)msg.getSerializedSize(); outputStream.writeByte(size); outputStream.write(msg.toByteArray()); and finally they are read like this: byte size = inputStream.readByte(); byte []bytes = new byte[size]; inputStream.readFully(bytes); MyProtoMessage.MyMessage msg = MyProtoMessage.MyMessage.parseFrom (bytes); With this protobuf approach I can do about 9K a second. I also tried writeDelimited/parseDelimited and it was even slower. Does this sound reasonable? I expected it to be faster than the standard Java serialization approach. Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~----------~----~----~----~------~----~------~--~---
