DEV Community

Bence Eros
Bence Eros

Posted on

Populating a Java POJO with Reflection vs. with the ClassFile API - small benchmark

I wanted to learn about the ClassFile API, and as a small pet project, I created a benchmark to compare how faster a generated class is than a reflection-based approach when we want to populate a POJO from a Map.

TL;DR: it turned out, the generated bytecode was 5x faster than using reflection.

Details here, enjoy: https://github.com/erosb/learn-classfile-api

And please prove me wrong if you find any mistakes in the benchmark :)

Top comments (0)