Benchmark of protobuf libraries using gcc 8.3.0 on an Intel(R) Core(TM) i7-4510U CPU @ 2.00GHz.
Libraries in this benchmark:
- FlatBuffers, an efficient cross platform serialization library for C++.
- Protocol Buffers for C++, the official Google implementation.
- Nanopb, protocol buffers with small code size.
- pbtools, this library.
- protobuf-c, Protocol Buffers implementation in C.
Library | Comment |
---|---|
flatbuffers | Easy to use. |
Easy to use. | |
nanopb | Repeated, bytes, strings, oneofs and submessages are hard to use by default, but easy if the max_size option is given. Otherwise easy. |
pbtools | Easy to use. |
protobuf-c | Fairly easy to use, but could use an allocator when building messages. |
Encoding time in milliseconds per library. Lower is better.
flatbuffers: ▇▇▇▇▇▇▇▇▇▇▇▇▇ 2506
google : ▇▇▇▇▇▇▇▇▇▇▇ 2231
nanopb : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 9580
pbtools : ▇▇▇▇▇▇▇ 1457
protobuf-c : ▇▇▇▇▇▇▇▇▇ 1892
Decoding time in milliseconds per library. Lower is better.
flatbuffers: ▏ 100
google : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 1997
nanopb : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 6433
pbtools : ▇▇▇▇▇▇▇▇▇▇▇▇ 1594
protobuf-c : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 2508
NOTE: flatbuffers decodes fields when used by the application, while other libraries decodes everything before any field can be used. The flatbuffers benchmark uses all fields once, while other libraries decodes all fields but does not use any.
Text segment size in bytes. Lower is better.
flatbuffers: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 40017
nanopb : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 21256
pbtools : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 17484
See Executable size in the Details section below for information about google and protobuf-c.
NOTE: The pbtools executabe size probably grows faster than others as it generates functions instead of tables.
Encoding Message
and Message3
2,000,000 times each for each library and optimization combination.
Library | Optimization | Exexution time [s] |
---|---|---|
pbtools |
|
|
pbtools |
|
|
protobuf-c |
|
|
protobuf-c |
|
|
protobuf-c |
|
|
protobuf-c |
|
|
|
|
|
flatbuffers |
|
|
pbtools |
|
|
pbtools |
|
|
|
|
|
flatbuffers |
|
|
nanopb |
|
|
nanopb |
|
|
nanopb |
|
|
nanopb |
|
|
Decoding Message
and Message3
2,000,000 times each for each library and optimization combination.
Library | Optimization | Exexution time [s] |
---|---|---|
flatbuffers |
|
|
flatbuffers |
|
|
pbtools |
|
|
pbtools |
|
|
pbtools |
|
|
pbtools |
|
|
|
|
|
|
|
|
protobuf-c |
|
|
protobuf-c |
|
|
protobuf-c |
|
|
protobuf-c |
|
|
nanopb |
|
|
nanopb |
|
|
nanopb |
|
|
nanopb |
|
|
size main-size
text data bss dec hex filename
14188 632 8 14828 39ec main-size
size main-size-lto
text data bss dec hex filename
11732 632 8 12372 3054 main-size-lto
size main-speed
text data bss dec hex filename
17484 656 8 18148 46e4 main-speed
size main-speed-lto
text data bss dec hex filename
15308 656 8 15972 3e64 main-speed-lto
size main-size
text data bss dec hex filename
18036 1066 32 19134 4abe main-size
size main-size-lto
text data bss dec hex filename
17002 1050 32 18084 46a4 main-size-lto
size main-speed
text data bss dec hex filename
21256 1082 32 22370 5762 main-speed
size main-speed-lto
text data bss dec hex filename
20566 1066 32 21664 54a0 main-speed-lto
$ size main-size
text data bss dec hex filename
58440 3032 664 62136 f2b8 main-size
$ size main-speed
text data bss dec hex filename
77538 3032 664 81234 13d52 main-speed
$ size main-size
text data bss dec hex filename
738258 25364 5760 769382 bbd66 main-size
$ size main-size-lto
text data bss dec hex filename
738034 25364 5760 769158 bbc86 main-size-lto
$ size main-speed
text data bss dec hex filename
738914 25236 5760 769910 bbf76 main-speed
$ size main-speed-lto
text data bss dec hex filename
739010 25236 5760 770006 bbfd6 main-speed-lto
size main-size
text data bss dec hex filename
19838 816 8 20662 50b6 main-size
size main-speed
text data bss dec hex filename
40017 728 8 40753 9f31 main-speed