thekvs/cpp-serializers

Benchmark comparing various data serialization libraries (thrift, protobuf etc.) for C++

C++

748

119 commits

updated Jan 28, 2020

See the code

README

About

Compare various data serialization libraries for C++.

Build

This project does not have any external serialization libraries dependencies. All (boost, thrift etc.) needed libraries are downloaded and built automatically, but you need enough free disk space (approx. 2.3G) to build all components. To build this project you need a compiler that supports C++14 features. Project was tested with Clang and GCC compilers.

  1. git clone https://github.com/thekvs/cpp-serializers.git
  2. cd cpp-serializers
  3. mkdir build
  4. cd build
  5. cmake -DCMAKE_BUILD_TYPE=Release ..
  6. cmake --build .

Usage

$ ./benchmark -h
Benchmark various C++ serializers
Usage:
  benchmark [OPTION...]

  -h, --help             show this help and exit
  -l, --list             show list of supported serializers
  -c, --csv              output in CSV format
  -i, --iterations arg   number of serialize/deserialize iterations
  -s, --serializers arg  comma separated list of serializers to benchmark
  • Benchmark all serializers, run each serializer 100000 times:
$ ./benchmark -i 100000
  • Benchmark only protobuf serializer, run it 100000 times:
$ ./benchmark -i 100000 -s protobuf
  • Benchmark protobuf and cereal serializers only, run each of them 100000 times:
$ ./benchmark -i 100000 -s protobuf,cereal

Results

Following results were obtained running 1000000 serialize-deserialize operations 50 times and then averaging results on a typical desktop computer with Intel Core i7 processor running Ubuntu 16.04. Exact versions of libraries used are:

  • thrift 0.12.0
  • protobuf 3.7.0
  • boost 1.69.0
  • msgpack 3.1.1
  • cereal 1.2.2
  • avro 1.8.2
  • capnproto 0.7.0
  • flatbuffers 1.10.0
  • YAS 7.0.2
serializerobject's sizeavg. total time
thrift-binary170171190.22
thrift-compact133783474.32
protobuf161162312.78
boost174701195.04
msgpack134022560.6
cereal174161052.46
avro163844488.18
yas17416302.7
yas-compact133212063.34

Size

Size

Time

Time

For capnproto and flatbuffers since they already store data in a "serialized" form and serialization basically means getting pointer to the internal storage, we measure full build/serialize/deserialize cycle. In the case of other libraries we measure serialize/deserialize cycle of the already built data structure.

serializerobject's sizeavg. total time
capnproto17768400.98
flatbuffers17632491.5

Time

Size measured in bytes, time measured in milliseconds.

apache-avro
avro
boost
capn-proto
cereal
c-plus-plus
cpp
flatbuffers
msgpack
performance-testing
protobuf
serialization
thrift
yas

thekvs/cpp-serializers

Benchmark comparing various data serialization libraries (thrift, protobuf etc.) for C++

C++

748

119 commits

updated Jan 28, 2020

See the code

README

About

Compare various data serialization libraries for C++.

Build

This project does not have any external serialization libraries dependencies. All (boost, thrift etc.) needed libraries are downloaded and built automatically, but you need enough free disk space (approx. 2.3G) to build all components. To build this project you need a compiler that supports C++14 features. Project was tested with Clang and GCC compilers.

  1. git clone https://github.com/thekvs/cpp-serializers.git
  2. cd cpp-serializers
  3. mkdir build
  4. cd build
  5. cmake -DCMAKE_BUILD_TYPE=Release ..
  6. cmake --build .

Usage

$ ./benchmark -h
Benchmark various C++ serializers
Usage:
  benchmark [OPTION...]

  -h, --help             show this help and exit
  -l, --list             show list of supported serializers
  -c, --csv              output in CSV format
  -i, --iterations arg   number of serialize/deserialize iterations
  -s, --serializers arg  comma separated list of serializers to benchmark
  • Benchmark all serializers, run each serializer 100000 times:
$ ./benchmark -i 100000
  • Benchmark only protobuf serializer, run it 100000 times:
$ ./benchmark -i 100000 -s protobuf
  • Benchmark protobuf and cereal serializers only, run each of them 100000 times:
$ ./benchmark -i 100000 -s protobuf,cereal

Results

Following results were obtained running 1000000 serialize-deserialize operations 50 times and then averaging results on a typical desktop computer with Intel Core i7 processor running Ubuntu 16.04. Exact versions of libraries used are:

  • thrift 0.12.0
  • protobuf 3.7.0
  • boost 1.69.0
  • msgpack 3.1.1
  • cereal 1.2.2
  • avro 1.8.2
  • capnproto 0.7.0
  • flatbuffers 1.10.0
  • YAS 7.0.2
serializerobject's sizeavg. total time
thrift-binary170171190.22
thrift-compact133783474.32
protobuf161162312.78
boost174701195.04
msgpack134022560.6
cereal174161052.46
avro163844488.18
yas17416302.7
yas-compact133212063.34

Size

Size

Time

Time

For capnproto and flatbuffers since they already store data in a "serialized" form and serialization basically means getting pointer to the internal storage, we measure full build/serialize/deserialize cycle. In the case of other libraries we measure serialize/deserialize cycle of the already built data structure.

serializerobject's sizeavg. total time
capnproto17768400.98
flatbuffers17632491.5

Time

Size measured in bytes, time measured in milliseconds.

apache-avro
avro
boost
capn-proto
cereal
c-plus-plus
cpp
flatbuffers
msgpack
performance-testing
protobuf
serialization
thrift
yas

Significant stargazers

Emilio Cobos Álvarez

737 followers · starred Sep 2015

Vitalie Spinu

197 followers · starred Dec 2016

qicosmos

1,949 followers · starred May 2021

Ilya Kulakov

109 followers · starred Feb 2017