C# 如何在MVC Mini Profiler中读取步骤计时?

C# 如何在MVC Mini Profiler中读取步骤计时?,c#,asp.net-mvc,performance,asp.net-mvc-4,mvc-mini-profiler,C#,Asp.net Mvc,Performance,Asp.net Mvc 4,Mvc Mini Profiler,在MVC mini profiler中,如何提取步骤计时以供自己使用?不只是在左上角的小盒子里展示它们(如考虑到我有台阶) using (var step = MiniProfiler.Current.Step("Foo")) { _fooService.Foo(); } using (var step = MiniProfiler.Current.Step("Bar")) { _barService.Bar(); } decimal fooTiming = what goe

在MVC mini profiler中,如何提取步骤计时以供自己使用?不只是在左上角的小盒子里展示它们(如考虑到我有台阶)

using (var step = MiniProfiler.Current.Step("Foo"))
{
    _fooService.Foo();
}

using (var step = MiniProfiler.Current.Step("Bar"))
{
    _barService.Bar();
}

decimal fooTiming = what goes here?
decimal barTiming = what goes here?

如何提取和读取上述步骤的计时,以便我可以使用这些数字执行任何操作?

如果您只想查看单个步骤的信息,则可以执行以下操作:

@{
    StackExchange.Profiling.Timing step;
    using (step = (StackExchange.Profiling.Timing)MiniProfiler.Current.Step("Test Step"))
    {
        System.Threading.Thread.Sleep(1000);
    }
    <div>
        @step.Name took @step.DurationMilliseconds ms 
    </div>
}
@{
StackExchange.Profiling.Timeing步骤;
使用(步骤=(StackExchange.Profiling.Timing)MiniProfiler.Current.step(“测试步骤”))
{
系统线程线程睡眠(1000);
}
@step.Name take@step.durationms
}
示例应输出如下内容:

测试步骤耗时1000.9毫秒

当它被释放时记录其持续时间的方法-尽管有点粗糙,
计时
对象的属性仍然可以访问

如果您想了解更多信息,可以始终遍历
MiniProfiler.Root
及其
子项
,尽管我从未在探查器运行时执行过此操作(即未调用
.Stop()