Test the influence of Protobuffer Definition Format on its time and space.

Source: Internet
Author: User

Test the influence of Protobuffer Definition Format on its time and space.

The following measure the number of bytes that the Protobuffer A command converts to std: string:

  • Add image resources

A) AddLayer: 108
B) AddSource: 209
C) MoveLayer: 44
D) DeleteLayer: 48

  • Clear screen: 36

However, the actual application uses the B command to receive and convert it to the C command. The C command is then split into the command, and the whole command receives A large number of bytes. The data is as follows:

  • Add image resources

A) AddLayer + AddSource: 410
B) MoveLayer: 150
C) DeleteLayer: 153

  • Clear screen: 123

From the comparison between the two, we can conclude that the two nesting commands bring about nearly 100 bytes of overhead. Obviously, the fewer layers of nesting, the smaller the number of bytes to be converted to the string. In addition, the search data shows that Protobuffer has a high time overhead when it contains the repeated element, because the memory is re-allocated when the number of repeated elements reaches a certain value. Therefore, from the perspective of time and space, there are two suggestions for Protobuffer definition. One is to use as few nesting as possible to reduce the space overhead (personal understanding, protobuffer definition should be flat); second, repeated elements should not be too many to reduce time overhead.

 


References:
Http://blog.csdn.net/yang3wei/article/details/46360099

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.