Home

Awesome

FlatBuffers performance comparison

This repository comes with benchmarking code for different FlatBuffer implementations across programing languages.

Setup

Results (more is better)

DateVariantReadWriteRead (w.bytes)Write (w.bytes)
2021-12-12Dart official FB v2.0.511 636 6607 907 0709 185 3256 176 130
2021-07-06Dart official FB master8 470 9854 063 4374 029 1973 036 950
2021-07-06Dart ObjectBox v1.1 FB11 296 7658 904 6455 989 8206 517 266
2021-02-26Dart official FB v0.128 197 20013 0603 831 74212 178
2021-02-26Dart official FB master8 878 4153 284 0454 032 7222 592 991
2021-02-26Dart ObjectBox v0.12 FB9 074 6605 044 8024 732 3404 212 460
2021-02-26Dart AOT ObjectBox v0.12 FB8 149 2703 821 1815 020 2203 189 186
2021-02-26Go9 920 6347 806 4018 438 8187 032 348

Note about results with a byte list: when reading a list from FlatBuffers in Dart, we call toList() to complete detach from the buffer (do not reference data inside the buffer). To be fair/have the numbers for comparison, we do the same in Go, though it doesn't have such a big impact there.

Benchmarked on 2021-12-12

$ dart run ./benchmark/flatbuffers_official.dart
Measuring performance without byte list
Builder(RunTime): 1.264690966438896 us.
Reader(RunTime): 0.8593531133503943 us.
Measuring performance with byte list
Builder(RunTime): 1.6191369028825495 us.
Reader(RunTime): 1.0886931055787357 us.

Benchmarked on 2021-07-06

Notes:

$ dart run ./benchmark/flatbuffers_official.dart
Measuring performance without byte list
Builder(RunTime): 2.4609702616502274 us.
Reader(RunTime): 1.1805002605954324 us.
Measuring performance with byte list
Builder(RunTime): 3.2927768109833697 us.
Reader(RunTime): 2.481883500446739 us.

$ dart run ./benchmark/flatbuffers_objectbox.dart
Measuring performance without byte list
Builder(RunTime): 1.123009326587794 us.
Reader(RunTime): 0.8852091727144895 us.
Measuring performance with byte list
Builder(RunTime): 1.5343855632803305 us.
Reader(RunTime): 1.6694992503948365 us.

Benchmarked on 2021-02-26 and before

Dart JIT

# v0.12
$ pub run benchmark/flatbuffers_official.dart
Measuring performance without byte list
Builder(RunTime): 765.6720244929201 us.
Reader(RunTime): 1.2199287561606402 us.
Measuring performance with byte list
Builder(RunTime): 821.0898645876077 us.
Reader(RunTime): 2.6097788216872186 us.

# master
$ pub run benchmark/flatbuffers_official.dart
Measuring performance without byte list
Builder(RunTime): 3.0450252660971455 us.
Reader(RunTime): 1.1263271653780544 us.
Measuring performance with byte list
Builder(RunTime): 3.856550051195625 us.
Reader(RunTime): 2.4797140891084815 us.

$ pub run benchmark/flatbuffers_objectbox.dart
Measuring performance without byte list
Builder(RunTime): 1.9822381638140623 us.
Reader(RunTime): 1.1019696605713052 us.
Measuring performance with byte list
Builder(RunTime): 2.3739097819326473 us.
Reader(RunTime): 2.113119513813462 us.

Dart AOT

We measured only the fastest variant (ObjectBox fork):

$ dart2native benchmark/flatbuffers_objectbox.dart --output bench && ./bench
Generated: /flatbuffers_benchmark/flatbuffers_dart_benchmark/bench
Measuring performance without byte list
Builder(RunTime): 2.616991849387036 us.
Reader(RunTime): 1.227103777393558 us.
Measuring performance with byte list
Builder(RunTime): 3.1355955587468918 us.
Reader(RunTime): 1.9919445761341137 us.

Go plain results

To get (closer) to what Dart does: execute 10 iterations of the same operation for each measured loop.

$ go test -bench .
goos: linux
goarch: amd64
pkg: flatbuffers_go_benchmark
BenchmarkBuilderWithoutBytesList-12       928960              1281 ns/op
BenchmarkReaderWithoutBytesList-12       1226929              1008 ns/op
BenchmarkBuilderWithBytesList-12          819072              1422 ns/op
BenchmarkReaderWithBytesList-12          1000000              1185 ns/op