Skip to content

Latest commit

 

History

History
69 lines (51 loc) · 3.27 KB

README.md

File metadata and controls

69 lines (51 loc) · 3.27 KB

Kotlin Avro Benchmark

This project contains a benchmark that compares the serialization / deserialization performance of the following avro libraries:

Each benchmark is executed with the following configuration:

  • Reading from a prepared byte array
  • Writing to a null output stream
  • All with the exact same schema generated by avro4k
  • Generating a maximum of use cases:
    • nullable fields
    • unions
    • arrays
    • records
    • enums
    • primitives (string, int, float, double, boolean)
    • logical types (date, timestamp-millis, char, uuid)
  • not benchmarking uuid as jackson uses a different representation (fixed) than avro4k and apache avro (string)

Results

Computer: Macbook air M2

Benchmark                                                       Mode  Cnt      Score      Error    Units  Relative Difference (%)
c.g.a.b.complex.Avro4kBenchmark.read                           thrpt    5   23897.142 ±   565.722  ops/s    0.00%
c.g.a.b.complex.ApacheAvroReflectBenchmark.read                thrpt    5   21609.748 ±   194.480  ops/s   -9.57%
c.g.a.b.complex.Avro4kGenericWithApacheAvroBenchmark.read      thrpt    5   14003.544 ±    41.383  ops/s  -41.42%

c.g.a.b.complex.Avro4kBenchmark.write                          thrpt    5   54174.691 ±    79.533  ops/s    0.00%
c.g.a.b.complex.ApacheAvroReflectBenchmark.write               thrpt    5   48289.132 ±  1718.797  ops/s  -10.85%
c.g.a.b.complex.JacksonAvroBenchmark.write                     thrpt    5   36604.599 ±   242.069  ops/s  -32.43%
c.g.a.b.complex.Avro4kGenericWithApacheAvroBenchmark.write     thrpt    5   28092.785 ±  1267.990  ops/s  -48.15%


c.g.a.b.simple.Avro4kSimpleBenchmark.read                      thrpt    5  174063.241 ±  7852.646  ops/s    0.00%
c.g.a.b.simple.ApacheAvroReflectSimpleBenchmark.read           thrpt    5  159204.806 ±   413.516  ops/s   -8.54%
c.g.a.b.simple.Avro4kGenericWithApacheAvroSimpleBenchmark.read thrpt    5  114511.133 ±   227.407  ops/s  -34.23%
c.g.a.b.simple.JacksonAvroSimpleBenchmark.read                 thrpt    5   67811.540 ±   212.367  ops/s  -61.05%

c.g.a.b.simple.Avro4kSimpleBenchmark.write                     thrpt    5  459751.939 ± 46513.718  ops/s    0.00%
c.g.a.b.simple.ApacheAvroReflectSimpleBenchmark.write          thrpt    5  355544.645 ± 14835.972  ops/s  -22.65%
c.g.a.b.simple.Avro4kGenericWithApacheAvroSimpleBenchmark.write thrpt   5  190365.959 ±  1014.944  ops/s  -58.60%
c.g.a.b.simple.JacksonAvroSimpleBenchmark.write                thrpt    5  131492.564 ± 10888.843  ops/s  -71.40%

Warning

JacksonAvroBenchmark.read is failing because of a bug in the library when combining kotlin and avro format.

Note

To add the relative difference, just ask to chatgpt "can you add another column in this benchmark that indicates the relative difference in percent regarding Avro4kDirectBenchmark:"

Run the benchmark locally

Just execute the benchmark:

../gradlew benchmark

You can get the results in the build/reports/benchmarks/main directory.

Other information

Thanks for @twinprime for this initiative.