Are someone of you using kodein on real project wi...
# kodein
n
Are someone of you using kodein on real project with large number of binds? How it performs compared to Dagger, which has statically compiled code? I am planning to have ~300-500 bindings on ~10 modules and injecting about 5000 times/second on single core.
i
I use Kodein on a production project so no issues there. It's a reasonably large project but we have done a lot of work to keep the total number of injections relatively low though we do have some deep chains on some provided dependecies. Our injections are mostly on demand injections to presenters which are triggered during activtiy/fragment initilization as expected. I don't have performance numbers as I've never needed to check, we support back to Lollipop and our older devices have no issues dropping frames from taking to long to load so whatever the 'cost' it doesn't really matter. Not sure what you are doing to need injections 5000 times/second however I would recommend you don't do that if it means accessing anything other than singletons given the GC pressure that happen creating 5000 new objects a second. If you are infact planning to use singletons then I don't think Kodein will cost you much in performance due to it's lookup implementation for singletons which generally only costs you the class lookup https://github.com/SalomonBrys/Kodein/blob/f08c8f251fc6a0439605d2d0c49ad54362b90ff3/shared/core/kotlin/com/github/salomonbrys/kodein/bindings/bindings.kt#L65
TLDR I don't think you'll have a problem but you should probably create a test to be sure you are not seeing a significant performance difference between the two libs. I would also be sure to weigh the ease of use of both libs in which I think Kodein is easier to teach and use compared to DI libraries that use code generation like Dagger2
n
I agree with you about benefits of Kodein. Also, where are more important, in the tests I am able mock only that I am needed with relative small boilerplate. However, I am coding a backend and I am need to be sure, every request has own scope and my project could easily reach 1000 req/sec
i
If you really need to handle that kind of traffic then you definitely need to be writing tests to emulate some of the stresses you expect so you can understand the performance pros/cons before committing to any framework.
n
The problem is, real-life is kind a different than synthetic tests 🙂 But I will try and share results