Display custom messages in MiniProfiler

I added a miniprofiler and can see the timings for all requests. Can I display trace messages (or any other special information) using Miniprofiler. Please help if possible. I am using it on MVC3.net C # website.

+3


source to share


2 answers


You can create subsections of code in your application using the following syntax:

using (MiniProfiler.Current.Step("Extremely Complex Stuff")) 
{
  var data = myClass.GetSomeDate();
  data.Process();
}

      

You can also add custom timing profiles (useful for profiling certain types of interactions other than sql, for example: redis / caching integration) with CustomTiming

:



using (MiniProfiler.Current.CustomTiming("Redis", "GetData")) 
{
  var data = CacheHelper.GetDataFromCache();
}

      

I would suggest cloning the repo and playing with the Sample.MVC app to see more things that can be done (these are demos of everything I said out of the box).

+3


source


Just a slight improvement on Yaakov's answer,

If you have included a cache key like



using (MiniProfiler.Current.CustomTiming("Redis", key)) 
{
  var data = CacheHelper.GetDataFromCache();
}

      

Then your MP tracks will be more useful as they tell you which keys are available and you will be alerted to any duplicates.

+1


source







All Articles