BT

Introducing the MVC Mini Profiler from Stack Exchange

by Jonathan Allen on Jun 20, 2011 |

Stack Exchange has released the ASP.NET MVC profiler that is used by Stack Overflow and its sister sites. This follows April’s release of Dapper, a “high performance Micro-ORM supporting Sql Server, MySQL, Sqlite, SqlCE, Firebird etc.” MVC Mini Profiler is an internal profiler requiring some modifications to the pages being examined.

Two global changes are needed to use the profiler. In the head of page, preferable a master page, a call is needed to include the necessary CSS and JavaScript files. Also required is JQuery 1.6.1. In Application_BeginRequest and Application_EndRequest calls are needed to start and stop the profiler.

Within a given view or controller the developer can then make calls to MiniProfiler.Current.Step inside a using block to tag a section of code. Each section so tagged appears in the resulting report. Steps can be nested to show whatever level of granularity is needed.

An especially useful feature of this profiler is its integration with database frameworks. In addition to .NET’s native DbConnection class there is built in support for Entity Framework and LINQ to SQL. The number of queries and the amount of time they take are included with whatever step was executing at the time. In order to detect common mistakes such as the N+1 anti-pattern the profiler will detect multiple queries that differ only by parameter values.

The profiler is available in NuGet under the name MiniProfiler and is licensed under Apache License, Version 2.0.

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT