Skip to content

felixguendling/cpp-serialization-benchmark

Repository files navigation

C++ Serialization Benchmark Build Status

This benchmark suite accompanies the public release of the Cista++ serialization library.

This repository contains benchmarks for C++ (binary & high performance) serialization libraries. The goal was to create a benchmark based on a non-trivial data structure. In this case, we serialize, deserialize and traverse a graph (nodes and edges). Since the goal was to have a data structure containing pointers, we choose an "object oriented" representation of a graph instead of a simple adjacency matrix. Some frameworks do no support cyclic data structures. Thus, instead of having node pointers in the edge object, we just reference start and destination node by their index. Benchmarks are based on the Google Benchmark framework.

This repository compares the following C++ binary serialization libraries:

Other Benchmarks

Build & Execute

To run the benchmarks you need a C++17 compatible compiler and CMake. Tested on Mac OS X (but Linux should be fine, too).

git clone --recursive github.com:felixguendling/cpp-serialization-benchmark.git
cd cpp-serialization-benchmark
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
./cpp-serialization-benchmark

Results

Library Serialize Deserialize Fast Deserialize Traverse Deserialize & Traverse Size
Cap’n Proto 76 ms 0.00 ms 0.0 ms 216 ms 221 ms 50.5M
cereal 216 ms 111.00 ms - 67 ms 174 ms 37.8M
Cista++ offset 4 ms 0.16 ms 0.0 ms 67 ms 66 ms 25.3M
Cista++ raw 650 ms 24.80 ms 24.8 ms 66 ms 91 ms 176.4M
Flatbuffers 1409 ms 35.70 ms 0.0 ms 75 ms 75 ms 63.0M
zpp_bits 4 ms 6.58 ms 6.6 ms 65 ms 72 ms 37.8M

Cista++ offset describes the "slim" variant (where the edges use indices to reference source and target node instead of pointers).

Exact results can be found here.

Benchmarks were run on Ubuntu 20.04 on an AMD Ryzen 9 5900X, compiled with GCC 11.

Compilation Times

Compilation times are measured with code generation but without building the code generators or static libraries (Cap’n Proto, Flatbuffers).

Library clang-7 on Mac OS X
Cap’n Proto 0.440s
cereal 1.827s
Cista++ raw 1.351s
Flatbuffers 0.857s

Contribute

You have found a mistake/bug or want to contribute new benchmarks? Feel free to open an issue/pull request! 😃