You might want to have a benchmark for this. Allocation in Java is cheap, but would increase the GC costs; resetting builder will introduce some CPU overhead (recursively setting data members and bit masks).
On Fri, Apr 22, 2011 at 6:15 AM, David Dabbs <[email protected]> wrote: > Hello. > > I have a PB builder I build and write to a stream from a servlet-based > webapp thousands of times/second. > Something like the following > > Protos.Response.Builder respBuilder = > Protos.Response.newBuilder().setFoo(12).setBar(345); // etc. . . > Protos.Response response = respBuilder.build(); > response.writeTo(getHttpRes().getOutputStream()); > > Would there be any performance advantage to having a ThreadLocal builder I > reset before processing each request? > > > Thank you, > David > > > -- > 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. > > -- 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.
