I generated xml and protobuf messages and it seems Protobuf message is 3.5 
times smaller than xml for my project.
I am very satisfied :)

However when it comes to *performance, I think I did something wrong..*
I use Spring boot and I have the following methods for Jmeter test.
The XML method below is 4-5 times faster than the Protobuf method. 

      @RequestMapping(value = "/getpbmsg")
@ResponseBody
ProtobufGeneratedFile.Pojo getPbMsg(@RequestBody Pojo pojo) throws 
IOException {
PojoToProtobufConvertor pbParser = new PojoToProtobufConvertor(pojo);
return pbParser.convertInboxPojo();
}
@RequestMapping(value = "/getxmlmsg", 
produces=MediaType.APPLICATION_XML_VALUE)
@ResponseBody
Pojo getXmlMsg(@RequestBody  Pojo pojo) throws IOException {
return pojo;
}

I convert a pojo to a ProtobufGeneratedFile.Pojo object. 
'ProtobufGeneratedFile' file was generated by 'protoc.exe'.
I produced a protobuf message in the following way,

ProtobufGeneratedFile.Pojo.newBuilder()

.setName(pojo.getFocusId())

.setTitle(pojo.getTotalMsgs())

.addAllMessage(


pojo.getMessages().stream().parallel()

.map(pojoMsg -> 

ProtobufGeneratedFile.Pojo.Message.newBuilder()

.setDate(pojoMsg.getDate())

.build())

.collect(Collectors.toList());


).build();

I am wondering if this is the most optimized way.
I think there is a better way to convert a pojo to a protobuf message.

Cheers
Seong

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to