In the first post on runtime code generation in Java, we looked at Java’s strong and static type system. Then we learned about different libraries for code generation and we had a closer look at Byte Buddy, a library of my own efforts.
Today we want to compare the different libraries in a benchmark. In the end, a shiny API will not be the only criteria for a best choice in code generation library. A library’s runtime performance might be an even more important factor, especially if the generated code takes up a crucial position within the running application.
We generate a microbenchmark and see if the performance of the different frameworks will allow us to draw any conclusion about which approach is better.