improve performance and reduce allocations
I've played around a bit and saw a lot of potential for improvements. The result should (😉 ) not alter public behavior but rather only improve performance / allocations:
This is the outcome for one of the Benchmarks
Master
| Method | Mean | Error | StdDev | Min | Max | Median | Rank | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|---|---|
| ResolveFromType.Current | 243.1 ns | 4.85 ns | 4.30 ns | 238.4 ns | 252.1 ns | 241.3 ns | 1 | 0.0548 | - | - | 344 B |
| ResolveAllFromType.Current | 613.3 ns | 11.31 ns | 10.58 ns | 599.4 ns | 634.4 ns | 611.0 ns | 1 | 0.1116 | - | - | 704 B |
PR
| Method | Mean | Error | StdDev | Min | Max | Median | Rank | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|---|---|
| ResolveFromType.Current | 168.2 ns | 1.80 ns | 1.50 ns | 166.5 ns | 171.8 ns | 168.0 ns | 1 | - | - | - | - |
| ResolveAllFromType.Current | 502.4 ns | 9.26 ns | 8.66 ns | 493.1 ns | 518.6 ns | 499.5 ns | 1 | 0.0343 | - | - | 216 B |
PS: I got some weird exception when I tried to run it on .net 4.5
System.Security.VerificationException : Operation could destabilize the runtime.
so could you please check whether this is a "doesn't work on my machine"-issue :)
Sorry @bollhals for the late reply. Thanks for the PR. It looks interesting with these numbers. Was the performance of BoDi a problem in your project? I would be interested in talking with you about it. Please get in touch with me on Discord.
But the problem for us is, that we just took over BoDi and aren't yet familiar with the codebase to a degree, were we are a little bit hesitant to merge it. So it will probably take some time until we merge it in.
unfortunately I also get the
System.Security.VerificationException : Operation could destabilize the runtime.exceptions. From all the unit tests I have 9 red ones with this exception. The exception is weird but not random, it comes every time when I run the tests. Did the unit tests run green for you?
I have now an environment that I can reproduce it, so I might be able to find the root cause for it.