mkarneim / pojobuilder

A Java Code Generator for Pojo Builders
Other
334 stars 44 forks source link

Add JMH performance benchmark #162

Closed drekbour closed 5 years ago

drekbour commented 5 years ago

Add some JMH tests covering performance of PojoBuilder-generated code in different scenarios. These are only run manually (./gradlew jmh) and are obviously not comparable across developers' machines. Below are the numbers on a very low-spec box.

They show the current cost of using withOptionalProperties also put to bed any idea that a ThreadLocal builder is better than creating a new one (yet to test how this scales vs multiple-threads-cloning-a-common-template)

I also checked the comparison of super.clone() vs manually copying each field and clone was actually 5% faster.

Benchmark                                                                           Mode  Cnt    Score   Error  Units
PojobuilderPerformance.constructManually                                           thrpt       244.293          ops/s
PojobuilderPerformance.constructViaBuilder_private                                 thrpt       150.680          ops/s
PojobuilderPerformance.constructViaBuilder_shared                                  thrpt       134.398          ops/s
PojobuilderPerformance.constructViaBuilder_threadlocal                             thrpt       136.498          ops/s
PojobuilderPerformance.constructViaButMethod_private                               thrpt       141.584          ops/s
PojobuilderPerformance.constructViaButMethod_shared                                thrpt       136.249          ops/s
PojobuilderPerformance.constructViaCopyMethod_private                              thrpt       142.470          ops/s
PojobuilderPerformance.constructViaCopyMethod_shared                               thrpt       125.537          ops/s
PojobuilderPerformance.constructViaOptionalBuilder_withOptionalProperties          thrpt       139.792          ops/s
PojobuilderPerformance.constructViaOptionalBuilder_withRealProperties              thrpt        64.063          ops/s
PojobuilderPerformance.constructViaOptionalSupplierBuilder_withOptionalProperties  thrpt       126.587          ops/s
PojobuilderPerformance.constructViaOptionalSupplierBuilder_withRealProperties      thrpt        58.997          ops/s
PojobuilderPerformance.constructViaOptionalSupplierBuilder_withSuppliedProperties  thrpt        93.973          ops/s
PojobuilderPerformance.constructViaSupplierBuilder_withRealProperties              thrpt       145.212          ops/s
PojobuilderPerformance.constructViaSupplierBuilder_withSuppliedProperties          thrpt        83.957          ops/s
coveralls commented 5 years ago

Coverage Status

Coverage decreased (-0.04%) to 87.555% when pulling f19dbda85d1bbd090a979ef4125947077b935e21 on drekbour:jmh into c4f79487541071ef0d7fe4057e835b33c5e21b5c on mkarneim:master.