[protobuf] Re: packed = true encoding in protobuf

2018-12-17 Thread ajinsight444
If I modify above code as below: p = address_book.add_people(); for(int j=0;j<5000;j++) { p->add_id(j); } Creating new person outside loop, then i can see the difference. with (packed = true) size is less (9882) as compared to without pack (14879). Is this the

Re: [protobuf] Re: packed = true encoding in protobuf

2018-12-10 Thread Josh Humphries
Looks like you create a new person in the loop, so each person has only a single ID. As Thomas mentioned, if you don't actually have multiple values, the framing is just overhead. With a single value, the encoding basically looks like so: - *With packed = false*: varint encoded tag, varint

[protobuf] Re: packed = true encoding in protobuf

2018-12-10 Thread ajinsight444
The code i am using is below: #include #include #include #include "addressbook.pb.h" #define FILENAME "ashu.pb" using namespace std; AddressBook address_book; int getFileSize() { ifstream file(FILENAME, ifstream::in | ifstream::binary); if(!file.is_open()) { return -1;

[protobuf] Re: packed = true encoding in protobuf

2018-12-10 Thread ajinsight444
On Friday, December 7, 2018 at 12:12:04 PM UTC+5:30, ajinsi...@gmail.com wrote: > > I am trying to find out difference in encoded size using packed equal to > true and without any packed encoding. I looped a int32 variable 5000 times. > With packed = true, i get size as 29876 and without