BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Introducing the MVC Mini Profiler from Stack Exchange

Introducing the MVC Mini Profiler from Stack Exchange

This item in japanese

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
Style

BT