Miniprofiler.Current method does not return the time

down vote


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

Any help is appreciated.

If the result says that you are using version 2.1 then you probably aren’t using v3.1.1. Please check your dll versions again and make sure that you are up to date.

I did not say that I am using older version. Right now I am using v3.1.1.139

Below line does not give me result. It returns (0 ms) in version
var profiler = StackExchange.Profiling.MiniProfiler.Current;

Is there any way to get current time of miniprofiler? Previously I use above line to get result in v2.1.0

Sorry, I misread your original post.

Can you include the code that you are using to run actual profiling steps? StackExchange.Profiling.MiniProfiler.Current is just a reference to the current mini profiler instance, but it doesn’t actually do anything by itself. That is what step() is for. Also, you are starting the MiniProfiler in App_BeginRequest, right?

Yes, Start() method of miniprofiler is written in App_BeginRequest. Moreover, I am looking for the same that you have mentioned “Current Mini Profiler Instance”.

Please see this link :
On top of this page it shows the time in green bar. But this is done using older version of miniprofiler 2.1.0 and using var profiler = StackExchange.Profiling.MiniProfiler.Current;

As I said before, above line does not return actual time with latest version of miniprofiler. It gives me 0 ms. Why so? Can you please explain me?

Can anybody help me with this?

From what I’ve seen you have to call .Stop() on MiniProfiler.Current in order for DurationMilliseconds to be filled in.