Note that there are some explanatory texts on larger screens.

plurals
  1. POStepping MVC Mini Profiler without nested usings
    text
    copied!<p>We're modelling a complicated system based around a complicated entity relationship in Dynamics CRM 4.0</p> <p>Due to the nature of development we've had to implement a repository style pattern and have lots of different providers that relate to each other.</p> <p>What I really want to do is to profile their constructors and various lazy getters, but I want to model this at the top level possible.</p> <p>The problem is, of course, Scope - If I wrap the constructor in a using block, it's not available to anything else. If I extend the using block so that everything that references the object I'm profiling comes into scope, then the profiler isn't just profiling the constructor - it's timing everything else.</p> <p>Similarly, there's a level of nesting, If I nest the usings correctly, then the code becomes unreadable.</p> <p>I've had a look at Profiler.Inline but that doesn't serve my purposes.</p> <p>What I'd really like to do is this:</p> <pre><code>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); </code></pre> <p>Does that make sense ? Hopefully I'm overlooking something in Mini Profiler, but I'd welcome any suggestions!</p> <p>I would like to remodel the code a bit, but there is no time for that and whilst it looks odd, we actually have a pretty good cyclomatic complexity.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload