Skip to main content

Benchmark

The source code of the benchmark is here, using H2's in-memory database, it can run directly without any environment preparation.

Report

Operation count per second

  • The abscissa represents the count of data objects queried from the database each time.
  • The ordinate represents the operation count per second.

Time cost per operation

  • The abscissa represents the count of data objects queried from the database each time.
  • The ordinate represents the time cost per operation(μs).
note

This benchmark does not include JPA(OpenJPA) as Spring has removed support for OpenJPA.

Implementation principle

  1. Disable caching for all frameworks

  2. All frameworks close the log

  3. All frameworks open and close connections/sessions each time without sharing; rely on the connection pool to ensure performance.

  4. Use Spring's connection management. Due to different framework APIs, the implementation methods are slightly different.

    but the end result is the same

  5. Don't use transactions

    Exposed is special, its API enforces transactions, provide fake implementation for it.

  6. Use the embedded H2 database to compress database consumption as much as possible, highlighting the performance of ORM itself, that is, the performance of mapping.

Value

A common point of view is that the performance of ORM itself is not important. In actual projects, the database is not embedded memory database, so the time consumption of the ORM itself is negligible compared to the time consumption of the database.

Rebuttal: After the release of Java 19, virtual threads are supported. ORM can complete the mapping as soon as possible, allowing the JVM to schedule more virtual threads.