Skip to content

oAwake/SerializeBenchmark

Repository files navigation

SerializeBenchmark

This project benchmarks the performance of various Java serialization frameworks:

  • SimpleBuffer (simple write, read string, varInt)
  • Google FlatBuffers
  • Google ProtoBuf
  • Kryo
  • Apache Fory

It measures serialization time, deserialization time, combined serialize+deserialize time, and serialized size.

Test Model

All benchmarks were performed using the following PlayerModel instance:

PlayerModel baseModel = new PlayerModel(
        UUID.randomUUID().toString(),
        "Awake",
        230,
        new ArrayList<>(List.of(1, 2, 3, 4, 5, 7, 8))
); 

Benchmark Results (100 Million Iterations)

Framework Serialize Time (ms) Deserialize Time (ms) Serialize + Deserialize Time (ms) Serialized Size (bytes) LOC
SimpleBuffer 14,517 9,372 23,304 59 33
FlatBuffers 33,141 9,870 44,269 124 36
ProtoBuf 22,725 11,349 28,995 57 21
Kryo 59,885 53,198 117,350 55 21
Apache Fory 7,420 10,129 18,779 63 15

LOC = line of code

Initial Observations

  • Apache Fory has the fastest serialization but slightly slower deserialization.
  • SimpleBuffer and ProtoBuf show balanced performance with small serialized sizes.
  • Kryo slows down significantly on high iteration counts, likely due to reflection overhead and dynamic class handling.
  • FlatBuffers produces larger serialized data but deserializes efficiently.

Recommendations for More Accurate Benchmarking

  1. Track memory usage with Runtime.getRuntime().
  2. Measure throughput (operations/sec) and average latency.
  3. Perform a JVM warm-up before the main benchmark to allow JIT compilation.
  4. Test with smaller batches (e.g., 1M iterations) to analyze scalability.

About Each Framework

  • SimpleBuffer – Lightweight and fast for basic models.
  • FlatBuffers – Zero-copy deserialization, slightly larger data.
  • ProtoBuf – Well-known, efficient, moderate speed.
  • Kryo – Flexible but slower for massive iterations.
  • Apache Fory – Code-generated serialization, extremely fast serialization speed.

About

Java serialization benchmark comparing SimpleBuffer, FlatBuffers, ProtoBuf, Kryo, and Apache Fory for speed, size, and complexity.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages