与MVC-迷你探查慢EF性能分析 [英] Slow EF profiling performance with mvc-mini-profiler

查看:223
本文介绍了与MVC-迷你探查慢EF性能分析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我创建一个使用这个函数的探查显示有关标准EF一个300ms的增加(第4版)上下文的创建方法,我的上下文。是否有另一种方式来做到这一点具有更好的性能?它违背了性能分析的目的是为

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);
    }

此第一种是使用上述函数来创建上下文。二是使用标准的EF上下文创建方法。下面是使用MVC-迷你分析器在性能上的差异:

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:

探查EF上下文:89.1结果
   一些DB命中:317.9

Profiler EF Context: 89.1
Some DB Hit: 317.9

普通EF上下文:0.1结果
   一些DB命中:7.4

Normal EF Context: 0.1
Some DB Hit: 7.4

更新2:
我没有在Visual Studio中的一些分析,它看起来像耗时的操作主要的时间是MvcMiniProfiler.Helpers.StackTraceSnippet.Get()和它里面有给System.Diagnostics.StackTrace..ctor(布尔)的调用。这需要很长的时间才能完成,似乎是上述延迟的原因。

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.

推荐答案

我已经推了<一个href=\"http://$c$c.google.com/p/mvc-mini-profiler/source/detail?r=4fb4fdb923372195f403b77421cf7379fcec5991\"相对=nofollow>变更到允许禁用堆栈跟踪,因为大量的查询可能会影响分析探查。

只是在应用程序启动设置如下设置:

Just set the following setting during application start:

MiniProfiler.Settings.ExcludeStackTraceSnippetFromSqlTimings = true;

这篇关于与MVC-迷你探查慢EF性能分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆