We model a complex system based on complex entity relationships in Dynamics CRM 4.0
Due to the nature of the development, we had to implement a repository style template and have many different providers that are related to each other.
What I really want to do is profile their constructors and various lazy getters, but I want to model this at the top level.
The problem, of course, is Scope - if I close the constructor in the using block, it will not be available for anything else. If I extend the used block so that everything that refers to the object that I am profiling falls into the scope, then the profiler does not just profile the constructor, but defines everything else.
Similarly, there is a level of nesting. If I insert the data correctly, then the code becomes unreadable.
I looked at Profiler.Inline, but that does not serve my purposes.
What I really would like to do is:
ref = Profiler.StartStep("Creating CRM Model"); //Do horrible CRM work var myNewHorribleObject = CRM.ModelHorribleStuff(...); Profiler.StopStep(ref); ref = Profiler.StartStep("How long does it take to get X"); var data = Repository.GetSomething(myNewHorribleObject.SomeId); Profiler.StopStep(ref); ref = Profiler.StartStep("How long does it take to get Y"); var newData = Repository.GetSomethingElse(myNewHorribleObject.ContextId); Profiler.StopStep(ref);
It makes sense? Hope I missed something in the Mini Profiler, but I would welcome any suggestions!
I would like to redo the code a bit, but there is no time for this, and while it looks weird, we really have pretty good cyclic complexity.