TDBIN Benchmarks

TDBIN Benchmarks

TDBIN is typeDiagram's compact binary codec for algebraic data types, measured here against Protocol Buffers and MessagePack. Every number below is data-derived — produced by src/scripts/tdbin/tdbin-bench-report.mjs from Criterion timings and exact encoder output — and regenerates on each benchmark run.

Scope: these figures are for the Rust implementation only. Both the encoded sizes and the speeds are measured against the Rust tdbin codec crate (src/tdbin), the Rust prost Protobuf encoder, and the Rust rmp-serde MessagePack encoder. The TDBIN wire format and its byte sizes are language-neutral, but serialize/deserialize speeds depend on each language's implementation — typeDiagram's other codec targets, and other Protobuf/MessagePack libraries, will differ, sometimes substantially.

Size and Speed

One row per test. Sizes are exact encoded bytes; "Serialize" is the whole ADT→binary conversion and "Deserialize" the whole binary→ADT conversion, each a Criterion median. typeDiagram is its framed production wire mode; MessagePack is struct-as-map (via rmp-serde). Lower is better in every column.

Test typeDiagram Size Protobuf Size MessagePack Size typeDiagram Serialize Protobuf Serialize MessagePack Serialize typeDiagram Deserialize Protobuf Deserialize MessagePack Deserialize
with_address 172 79 142 86.21 ns 46.82 ns 240.50 ns 157.32 ns 150.50 ns 192.39 ns
without_address 124 31 100 63.80 ns 32.86 ns 227.40 ns 76.85 ns 50.06 ns 108.75 ns
metric_batch 43,788 84,149 90,440 6.557 us 45.616 us 43.619 us 5.198 us 29.664 us 52.304 us
person_batch 22,988 29,184 61,963 9.728 us 17.986 us 48.369 us 35.157 us 55.844 us 87.035 us
contact_batch 23,156 35,221 80,162 9.169 us 24.761 us 67.893 us 30.351 us 59.681 us 92.548 us
diagram_document 45,172 50,788 77,410 10.259 us 21.699 us 57.093 us 69.248 us 109.277 us 130.848 us
event_batch 116,372 131,744 230,620 34.150 us 69.852 us 139.987 us 193.619 us 275.241 us 372.344 us

What the numbers show

The following are read directly off the table above — each is a comparison of the measured values, nothing more:

Methodology

Test machine

Field Value
Platform darwin 25.5.0 (arm64)
CPU Apple M4 Max
Logical CPUs 14
Memory 36.0 GiB
Rust rustc 1.97.0 (2d8144b78 2026-07-07)
Cargo cargo 1.97.0 (c980f4866 2026-06-30)

Reproduce

Run the benchmark, then regenerate this page: