Benchmarking Dart’s json serialization and dataclass ecosystem

Helight
1 min readJan 21, 2024

Being the author of a serialization framework myself, I have always been comparing my package’s performance to other packages it is competing with. Recently, I expanded packages tested by the benchmark project, to include most of the commonly used serialization packages and dataclass generators.

Legend

dogs: dogs_core
json_ser: json_serializable
built: built_value
mappable: dart_mappable
d_j_m: dart_json_mapper

Excluded

This excludes packages with their own serialization system, since they are hard to compare.

Conclusion

While most of the popular packages like freezed, json_serializable and built_value (and dogs_core) generally perform similar on serialization benchmarks, dart_mappable and most importantly dart_json_mapper lack behind massively, being 2x and 20x slower than their alternatives.

Looking at equality implementations, equatable and dart_mappable perform worse than their competitors, with dart_mappable being by far the slowest solution.

While those benchmarks are interesting, their practical meaningfulness may vary with different data structures and the use-cases. The performance impact on Flutter applications is relatively low, as most time is probably spent on rendering, rather than serialization. Though when choosing a serialization framework for dart backends or applications with high serialization workloads, you may want to choose on of the more performant packages, like built_value, json_serializable, freezed or dogs_core.

Source

--

--