Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use the mvc mini profiler in a console application?

Tags:

How can I use the mvc-mini-profiler in a C# console application?

Also curious, does the mvc mini profiler put the actual profiled statistics in the left side of each web page or is that just custom javascript code done manually?

I downloaded and ran the mvc sample, and can't find that code that puts the results in that javascript popup.

like image 321
Blankman Avatar asked Sep 11 '11 11:09

Blankman


People also ask

What is MiniProfiler C#?

MiniProfiler is an open source profiling library which monitors the performance of a . NET application. It is very lightweight and fast. Using this, we can easily track a performance issue with our application. It was created by Stack Overflow Team members.


2 Answers

yes you can! And I have created a NuGet package to make it even easier to get it running.

Check out MiniProfiler.Windows: http://nootn.github.com/MiniProfiler.Windows/

Also for a detailed article on how to design a good console app for profiling: http://healthedev.blogspot.com.au/2012/07/performance-profiling-console-or-winwpf.html

like image 52
nootn Avatar answered Oct 01 '22 14:10

nootn


The core timing object (MiniProfiler) should work OK, as should the profiled-connection hooks etc; however you would need to;

  • add your own UI to show the results
  • define your own scope / lifetime (for web it is easy - just the http-request)
  • provide your own storage hooks (there is an extension API for this, that uses http-context by default IIRC)
  • either pass the profiler around manually, or define a sensible way to look up the current profiler instance

I know some people have used portions of it for WPF etc, so it can be used - but IMO it might make sense to pick just the bits that make sense, and use those to write a custom library that adds some awesome.

like image 25
Marc Gravell Avatar answered Oct 01 '22 15:10

Marc Gravell