This benchmark compares serialization and deserialization throughput in JavaScript for Apache Fory, Protocol Buffers, and JSON.
It mirrors the benchmark layout used by benchmarks/cpp and uses the shared schema in benchmarks/proto/bench.proto.
NumericStructSampleMediaContentNumericStructListSampleListMediaContentListFor Fory, all struct schemas use explicit type IDs and field IDs so compatible-mode type metadata stays compact. The numeric type IDs match the C++ benchmark registration order.
cd benchmarks/javascript ./run.sh
./run.sh --help Options: --data <struct|sample|mediacontent|structlist|samplelist|mediacontentlist> Filter benchmark by data type --serializer <fory|protobuf|json> Filter benchmark by serializer --duration <seconds> Minimum time to run each benchmark
Examples:
./run.sh --data struct ./run.sh --serializer fory ./run.sh --data sample --serializer protobuf --duration 10
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 and JSON benchmark modes fail with a configuration error. Fory serialization uses the normal v1 schemas, and Fory deserialization uses v2 schemas registered with the same Fory type IDs where one int32 field is widened to int64.
Running the pipeline writes:
benchmarks/javascript/benchmark_results.jsondocs/benchmarks/javascript/throughput.pngdocs/benchmarks/javascript/README.mdjavascript/ before running.protobufjs with the shared bench.proto schema.