Miniprofiler.Current method does not return the time

牧云@^-^@ 提交于 2019-12-11 01:52:05

问题


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

var profiler = StackExchange.Profiling.MiniProfiler.Current;

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

This method gives me result with MiniProfiler version 2.1.0.

Right now I am using MiniProfiler version 3.1.1.139.


回答1:


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.

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.

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).



来源:https://stackoverflow.com/questions/25255960/miniprofiler-current-method-does-not-return-the-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!