Slow EF profiling performance with mvc-mini-profiler

When I create my context using the below function the profiler shows about a 300ms increase from the standard EF (version 4) context creation method. Is there another way to do this that has better performance? It defeats the purpose of performance profiling as is.

    public static Models.MyEntities GetContext()
    {
        var profiler = MiniProfiler.Current;
        var sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnString"].ConnectionString);
        var profiledConnection = MvcMiniProfiler.Data.ProfiledDbConnection.Get(sqlConn, profiler);
        return ObjectContextUtils.CreateObjectContext<Models.MyEntities>(profiledConnection);
    }

This first one is using the above function to create the context. The second is using the standard EF context creation method. Here is the difference in performance using the mvc-mini-profiler:

Profiler EF Context: 89.1 Some DB Hit: 317.9

Normal EF Context: 0.1 Some DB Hit: 7.4

UPDATE 2: I did some profiling in Visual Studio and it looks like the main time consuming operation is MvcMiniProfiler.Helpers.StackTraceSnippet.Get() and inside it there is a call to System.Diagnostics.StackTrace..ctor(bool). This takes a long time to complete and seems to be the cause of the above delay.

Answers


I've pushed a changeset to the profiler that allows disabling of stack traces, since lots of queries could impact profiling.

Just set the following setting during application start:

MiniProfiler.Settings.ExcludeStackTraceSnippetFromSqlTimings = true;

Need Your Help

python in Google App Engine - having the class-instead-of-instance problem, but using db.Model so can't create init method

python google-app-engine list set

i am writing an app to compare products, using Python and GAE. The products will belong to a set of similar products, and the app calculates the best value in each set.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.