Introducing the MVC Mini Profiler from Stack Exchange
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.
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.
Stuart Williams Aug 02, 2015