<@U0BHTDH55> Have you looked at the source code of...
# kodein
s
@pawel_byszewski Have you looked at the source code of the benchmark ? You should always read the code of benchmarks to understand what exactly is being benchmarked. In this case here are : - The Java code : https://github.com/evant/kotlin-hidden-costs-benchmark/blob/android/src/main/java/com/athaydes/kotlin/part3/JavaExamples.java - The Kotlin code : https://github.com/evant/kotlin-hidden-costs-benchmark/blob/android/src/main/java/com/athaydes/kotlin/part3/kotlin-sources.kt You may see that the Java & Kotlin code are not equivalent : the Java code is just plain access with explicit initialization while the kotlin code is lazy access with caching on first access. I am far from being a JVM expert, so I do not know how much of a difference that would make, but IMHO, in its current state, this benchmark is broken. However, delegates are bound to make a performance difference because of the
KProperty
parameter that is passed to the function. Also, as Andreas said, DI is not a critical path : most often than not, spending time to optimize it is loosing time since it does not make any notable difference in the app.