开发者

Which protobuf optimization?

开发者 https://www.devze.com 2023-01-30 06:19 出处:网络
Using google\'s protocol buffer compiler for c++ its not clear which is faster: optimize for speed: option optimize_for = SPEED;

Using google's protocol buffer compiler for c++ its not clear which is faster: optimize for speed:

option optimize_for = SPEED;

or optimize for light runtime:

开发者_开发技巧
option optimize_for = LITE_RUNTIME;

if speed is faster, what makes it faster? does anyone have hard data on the subject?


The way I read the documentation,

  • optimize for CODE_SIZE does not generate fast accessor methods for everything, but relies on slow reflection,

  • optimize for SPEED will give you the fast accessors

  • and optimize for LITE_RUNTIME will also give you fast accessors, but does not support the full functionality of protobuf, but only the lighter subset protobuf-lite. Basically, this means descriptors or reflection are not available.

So I guess, LITE_RUNTIME is not slower than SPEED, and you should choose depending on which runtime library you want to require (lite or full).

if speed is faster, what makes it faster?

SPEED is faster compared to CODE_SIZE, because it uses autogenerated code instead of runtime reflection.

0

精彩评论

暂无评论...
验证码 换一张
取 消