-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add API to analyse object composition time #722
Comments
feature-722 branch created. |
Open questions:
Things to consider:
|
…HelperActivator from the IServiceProvider instead of creating the DefaultTagHelperActivor manually; that breaks in ASP.NET Core 3.0 as both DefaultTagHelperActivator and ITypeActivatorCache are now internal types. Fixes #722.
Moved this back to the backlog. There are too many open questions and caveats at this point. |
I was going to create a similar issue but luckily found this one. I would very much be interested in the ability to intercept all object creation invocations for a similar purpose: profiling startup performance of a large project to aid in finding the "only assignments in constructor" rule violations. |
See this thread for a mand-made solution: #941 |
When it comes to constructing object graphs of large applications, it can get hard to keep track of what developers check in and spot when they accidentally create constructors that do too much.
Simple Injector could help in this regard by doing an optional scan of the complete object graph to measure the time it takes construct graphs. This analysis can be reported back to the user in some form. This is especially useful in integration testing or exploratory testing scenarios, where a developer likes to detect or prevent performance problems, caused by constructors that do I/O or other heavy lifting.
I'm still unsure what the correct API for this would be and that the APIs entry point should be.
Simple Injector currently contains one interception point that allows you to measure performance, which is
Container.Options.RegisterResolveInterceptor
, but this interception point allows only root objects to be measured, for instance:This code, however, only plugs into the root objects, while the real culprit might lie in an object very deep in the object graph. The real cause will be hard to track.
There is a
Container.RegisterInitializer
overload that allows to hook into individual registrations, but this method, however, only gets triggered after the object is created. This, therefore, isn't helpful.The only feasible way to plug in, is to hook onto the
ExpressionBuilding
event, and replace the builtExpression
with one that adds measurement. This, however, is cumbersome. It would be much nicer if such feature is supported out-of-the-box.The text was updated successfully, but these errors were encountered: