This benchmark compares Apache Fory C#, protobuf-net, and MessagePack-CSharp.
Serializer setup used in this benchmark:
fory: Fory.Builder().Compatible(true).Build()protobuf: protobuf-net runtime serializermsgpack: MessagePackSerializer.Typeless with TypelessContractlessStandardResolvercd benchmarks/csharp ./run.sh
This runs all benchmark cases and generates:
build/benchmark_results.jsonreport/README.mdreport/throughput.png./run.sh --help Options: --data <struct|sample|mediacontent|structlist|samplelist|mediacontentlist> --serializer <fory|protobuf|msgpack> --duration <seconds> --warmup <seconds>
Examples:
# Run only struct benchmarks ./run.sh --data struct # Run only Fory benchmarks ./run.sh --serializer fory # Use longer runs for stable numbers ./run.sh --duration 10 --warmup 2
Set FORY_BENCH_SCHEMA_MISMATCH=1 to run the Fory-only compatible-read schema-mismatch mode. This mode is off by default. When enabled, run with --serializer fory; protobuf-net and MessagePack benchmark modes fail with a configuration error. Fory serialization uses the normal v1 benchmark models, and Fory deserialization uses v2 models registered with the same Fory type IDs where one int32 field is widened to int64.
struct: 8-field integer objectsample: mixed primitive fields and arraysmediacontent: nested object with list fieldsstructlist: list of struct payloadssamplelist: list of sample payloadsmediacontentlist: list of media content payloadsEach case benchmarks:
Latest run (Darwin arm64, .NET 8.0.24, --duration 2 --warmup 0.5):
| Serializer | Mean ops/sec across all cases |
|---|---|
| fory | 2,032,057 |
| protobuf | 1,940,328 |
| msgpack | 1,901,489 |
Per-case winners vary by payload and operation. The full breakdown is generated at:
benchmarks/csharp/build/benchmark_results.jsonbenchmarks/csharp/report/README.mdbenchmarks/csharp/report/throughput.png