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 correct way I am checking impact of packed encoding?
On Friday, December 7, 2018 at 12:12:04 PM UTC+5:30, [email protected]
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 packed encoding, i get
> size as 24876. I am confused why i get opposite results. As per my
> understanding, size with packed should be less as compared to non packed.
> Can anyone please explain what the issue is?
> My proto file is below for non packed and for packed i modify id filed as;
> repeated int32 id = 2[packed=true]:
>
> syntax = "proto2";
> message Person {
> optional string name = 1;
> repeated int32 id = 2;
> optional string email = 3;
>
> enum PhoneType {
> MOBILE = 0;
> HOME = 1;
> WORK = 2;
> }
>
> message PhoneNumber {
> optional string number = 1;
> optional PhoneType type = 2 [default = HOME];
> }
>
> repeated PhoneNumber phones = 4;
> }
>
> message AddressBook {
> repeated Person people = 1;
> }
>
--
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.