-
Notifications
You must be signed in to change notification settings - Fork 152
Description
In our test performance profiling sessions we've noticed that AllowOverridingRegistrations might be partly responsible for slowness in our tests. The code seems to be doing a linear search on providers to remove existing ones. Since our container is pretty heavy (with thousands of registrations for each test case), this RemoveAll call showed up in our profiling sessions. This is obviously not a problem on prod because we use a single container and do the registrations once on startup but in our test, we use a separate container for each test case and register everything (our tests are more like integration tests than unit tests).
Here is a screenshot from a profiling session that ran 150 tests. RemoveAll was called 5M times and its predicate was called over a billion items (see op_Equality and get_ServiceType). Comparison is of course very fast but when called billions of thems, it adds up to a significant amount of time
I am not sure if it is easy or worthwhile to improve this code for the majority of the users (maybe we are an outlier) but it'd be very useful if you could provide methods like RegisterWithOverride, which would allow us to pay this cost only when we are actually overriding registrations in test setup.
