Miniprofiler.Current方法不返回时间 [英] Miniprofiler.Current method does not return the time

查看:144
本文介绍了Miniprofiler.Current方法不返回时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用MiniProfiler来获取这段代码的时间.

I'm trying to get time with this code using MiniProfiler.

var profiler = StackExchange.Profiling.MiniProfiler.Current;

但是它返回结果0 ms.如何在miniprofiler中获取current time.

But it returns 0 ms in result. How to get current time in miniprofiler.

此方法为我提供MiniProfiler version 2.1.0.

现在我正在使用MiniProfiler version 3.1.1.139.

推荐答案

您可以通过访问StackExchange.Profiling.MiniProfiler.Current.DurationMilliseconds获取当前MiniProfiler的总运行时间-但仅在之后,当前的MiniProfiler具有已停止(仅此时已填充).在停止之前,活动的MiniProfiler实例将没有设置此属性.

You can get the total elapsed time for the current MiniProfiler by accessing StackExchange.Profiling.MiniProfiler.Current.DurationMilliseconds - but only after the current MiniProfiler has been stopped (it is only populated at that point). Before it is stopped, an active MiniProfiler instance will not have this property set.

现在无法获取活动MiniProfiler实例的经过时间.有一个名为 ElapsedTicks 的内部属性但是,由于这是一个内部属性,因此您无法在MiniProfiler程序集之外访问它.

There is no way right now to get the elapsed time for an active MiniProfiler instance. There is an internal property called ElapsedTicks but as this is an internal property, you cannot access it outside of the MiniProfiler assembly.

如果对于活动的MiniProfiler实例而言,访问此数据非常重要,那么您可以派生当前版本并将属性切换为公共属性(尽管在执行此操作之前,我会问您使用什么功能)的情况是-也许还有另一种方法可以实现.)

If it is super-important for you to be able to access this data for an active MiniProfiler instance, than you could fork the current build and switch the property to be public (though before you do this I would question what your use case is - perhaps there is another way to achieve this).

这篇关于Miniprofiler.Current方法不返回时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆