BT

New Early adopter or innovator? InfoQ has been working on some new features for you. Learn more

Introducing the MVC Mini Profiler from Stack Exchange

| by Jonathan Allen on Jun 20, 2011. Estimated reading time: 1 minute |

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.

Rate this Article

Adoption Stage
Style

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

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT