I'd like to use MiniProfiler from time to time to profile my code, but I don't want to branch off and keep re-introducing it; I'd like to leave it in there and just remove the @MiniProfiler.RenderIncludes()
call from my layout template when I'm not using it. However, my code would still look like this:
using (MiniProfiler.Current.Step("Generate events index view model")) {
_thisStep = MiniProfiler.Current.Step("Check query string");
int pageIndex = 0;
// Do check...
_thisStep.Dispose();
// Do other stuff...
}
How much overhead would leaving those Step
s in there and disposing them cause? Is there a way to tell MiniProfiler I'm not using it so that Step
basically does nothing, but I can still leave it in my code?
DisposeIfNotNull()
extension method I created. The example just uses the standard method. :-) – Stalinist