Make the Head property public so that I can use it, or add the below Extension
Methods.
I do not like the
using (profiler.Step("Step A"))
{
// some code here to profile
var someData = GetSomeData();
}
pattern as it messes up the scope of anything happening in that using block.
Especially if it is defined as a var and the type is somekind of anonymous type
that is the result of say a Linq statement (yes that does not match with the
above example ;-).
So I'd like to create these extension methods:
namespace MvcMiniProfiler
{
public static class MiniProfilerExtenstions
{
public static void StartStep(this MiniProfiler profiler, string name)
{
if (profiler == null) return;
var t = new Timing(profiler, profiler.Head, name);
}
public static void StopStep(this MiniProfiler profiler)
{
if (profiler == null) return;
profiler.Head.Stop();
}
}
}
Then I can do:
MiniProfiler.Current.StartStep("Step A");
var someData = from x in repository.Xs
// add some insane Linq Foo here
select x;
MiniProfiler.Current.StopStep();
// use someData in some awesome way
This is perhaps less elegant than the using style, but would work quite well
too.
[I do not get (see) the design decision that makes the Timing class take
control of the Head property. Anyone care to explain?)]
Original issue reported on code.google.com by rudi.la...@gmail.com on 25 Aug 2011 at 1:21
Original issue reported on code.google.com by
rudi.la...@gmail.com
on 25 Aug 2011 at 1:21Attachments: