(Since you said getserializedsize I'm assuming Java) There isn't a precanned way to get a breakdown of the serialized sizes, but I don't think you need to reimplement the entire parser: if you take a serialized message, you could set up a CodedInputStream and use a fairly simple loop of readTag(), skipField(), and getTotalBytesRead() to compute the size per field. skipField() will skip over entire submessages though, so if you are interested in those sub fields, you'll need to handle them separately.
As an aside, are you serializing all of those records as a single protobuf? You might consider splitting those up so each record is serialized individually, or at least in smaller blocks. This doesn't help you reduce the overall serialized size, but may be useful to help control in memory size. 2010/1/26 Kalle Kärkkäinen <[email protected]> > Hi, > > Is there some way to analyse field sizes? I've got a structure that > contains some 5000 - 10000 records and I'd really like to know what > takes up the space. It is not problematic at this point, total size is > under 500k, but knowing the ratio per field would help. I've > calculated current data with getserializedsize. > > Would I need to reimplement the parsing to get the ratios? Is there > some other way? > > -- > Kalle > > -- > 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]<protobuf%[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.
