gustavopsantos / Reflex

Minimal dependency injection framework for Unity
MIT License
730 stars 51 forks source link

Benchmark comparison #54

Closed boraty14 closed 5 months ago

boraty14 commented 5 months ago

Screenshot 2024-06-01 104656

I wanted to check out benchmarks locally, and reflex sample literally takes 4 seconds for each iteration and freezes unity. Is it an old sample? According to documentation Reflex should be both faster and less garbage allocated.

gustavopsantos commented 5 months ago

@boraty14 Hello o/

  1. If you have reflex debugger on, disable it, its heavy.
  2. Also prefer to test it on a release build (without debugging enabled).

Like so: image

gustavopsantos commented 5 months ago

@boraty14 Please let me know if that worked, or if you have any other questions ;)

boraty14 commented 5 months ago

Okay that was my bad, got a similar result once I disabled the debugger, so thanks!

And since you asked, how injection works for dynamically created monobehaviors? If it is on the scene from start it works but not if I create it at runtime. Tried to find some examples for it but could not find it in docs, Reflex looks really neat overall but I believe some more examples would be awesome, and thanks for your work!

gustavopsantos commented 5 months ago

@boraty14 If objects (pure c# objects or unity objects) are created during runtime, theres no way reflex can detect this creation to auto inject the object, this needs to be done manually.

boraty14 commented 5 months ago

Thanks for the fast reply! I also saw that, part and once again I went through the manual. What confuses me is, altough I get the general idea with scoping, how do I get ahold of the container, especially the project and scene container. Even for manual scoping, I need a reference to parent container but where do I get that? Thanks!

boraty14 commented 5 months ago

Okay It is through extensions, found that one :D so thanks anyway @gustavopsantos for your replies! It was my fault for not seeing it, but even though I believe it would be highlt appreciated adding some intermediate examples to the examples. Keep up the good work!