日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

使用MiniProfiler跟踪MVC + EF + Bootstrap 2 权限管理系统的性能消耗

發布時間:2024/6/21 windows 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 使用MiniProfiler跟踪MVC + EF + Bootstrap 2 权限管理系统的性能消耗 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

安裝MiniProfiler

在MVC + EF + Bootstrap 2 權限管理系統入門級(附源碼)文章中下載了它的源碼,調試模式下打開一個頁面都要再2.5秒以上,所以使用MiniProfiler、MiniProfiler.MVC4 、MiniProfiler.EF6組件進行了分析。

首先,依次序安裝組件。然后,修改Global.aspx.cs 文件:

protected void Application_Start(){AreaRegistration.RegisterAllAreas();WebApiConfig.Register(GlobalConfiguration.Configuration);FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);RouteConfig.RegisterRoutes(RouteTable.Routes);BundleConfig.RegisterBundles(BundleTable.Bundles);//自定義View ViewEngines.Engines.Clear();ExtendedRazorViewEngine engine = new ExtendedRazorViewEngine();engine.AddPartialViewLocationFormat("~/Areas/Common/Views/Shared/{0}.cshtml");engine.AddPartialViewLocationFormat("~/Areas/Common/Views/Shared/{0}.vbhtml");ViewEngines.Engines.Add(engine);//Model去除前后空格ModelBinders.Binders.DefaultBinder = new TrimModelBinder();//設置MEF依賴注入容器 MefConfig.RegisterMef();//初始化EF6的性能監控 MiniProfilerEF6.Initialize();//初始化DB DatabaseInitializer.Initialize();}protected void Application_BeginRequest(){StackExchange.Profiling.MiniProfiler.Start();}protected void Application_EndRequest(){StackExchange.Profiling.MiniProfiler.Stop();}

? ?MiniProfilerEF6.Initialize(); 一定要放在?DatabaseInitializer.Initialize(); 之前,否則會報如下錯誤:

An exception of type 'System.InvalidOperationException' occurred in EntityFramework.dll but was not handled in user code.?Additional information:?The Entity Framework was already using a DbConfiguration instance before an attempt was made to add an 'Loaded' event handler. 'Loaded' event handlers can only be added as part of application start up before the Entity Framework is used."

運行站點有可能還會遇到這個錯誤:

An exception of type 'System.Data.SqlClient.SqlException' occurred in MiniProfiler.dll but was not handled in user code

Additional information: Invalid column name 'CreatedOn'.

解決方法是:

1.禁用這種類型的異常斷點(不可取)

2.刪除packages\MiniProfiler.3.2.0.157\lib\net40 下的MiniProfiler.PDB文件(我是這么做的)

3.禁用EF的數據庫變化跟蹤(未驗證,應該管用)

Found an answer for my question. Thanks all for replies.Database.SetInitializer<MyContext<Label>>(null); This fixes the problem and disables DB changes tracking in EF.

運行站點打開登陸頁

Sql占了47.7%,點開可以查看執行了哪些sql語句。

?

分析頁面耗時

首先,調試模式下運行Debug和Release代碼,耗時差不多都很長,截圖如下:

?

? ??

? ?

然后,非調試模式(Ctrl+F5)運行,截圖如下:

?

非調試模式(Ctrl+F5)的效率還是挺不錯的,沒想到和調試模式(F5)差別會這么大。使用必應搜了一下找到一個帖子 :Visual C++: Difference between Start with/without debugging in Release mode

里面的解釋是

The problem is that Windows drops in a special Debug Heap, if it detects that your program is running under a Debugger. This appears to happen at the OS level, and is independent of any Debug/Release mode settings for your compilation.

You can work around this 'feature' by setting an environment variable: _NO_DEBUG_HEAP=1

This same issue has been driving me nuts for a while; today I found the following, from whence this post is derived: http://blogs.msdn.com/b/larryosterman/archive/2008/09/03/anatomy-of-a-heisenbug.aspx

?另外為了更細化的跟蹤某個方法的耗時可以在代碼中這么寫:

public AdminLayoutAttribute(){//TODO: Test//var userRole = new List<UserRole> { new UserRole { Id = 1, UserId = 1, RoleId = 1 } };//var user = new User { Id = 1, LoginName = "admin", LoginPwd = "8wdJLK8mokI=", UserRole = userRole };//SessionHelper.SetSession("CurrentUser", user);var user = SessionHelper.GetSession("CurrentUser") as User;if (user != null){// using (StackExchange.Profiling.MiniProfiler.StepStatic("AdminLayout")) using (MiniProfiler.Current.Step("AdminLayout")){// Enqueue a jobvar container = System.Web.HttpContext.Current.Application["Container"] as CompositionContainer;UserService = container.GetExportedValueOrDefault<IUserService>();RoleService = container.GetExportedValueOrDefault<IRoleService>();RoleModulePermissionService = container.GetExportedValueOrDefault<IRoleModulePermissionService>();ModuleService = container.GetExportedValueOrDefault<IModuleService>();ModulePermissionService = container.GetExportedValueOrDefault<IModulePermissionService>();PermissionService = container.GetExportedValueOrDefault<IPermissionService>();}}}

再次訪問模塊管理時就可以看到AdminLayout的耗時了,好像耗時特別小時這里就不記錄

?

總之有這么一個組件確實可以量化執行過程的耗時。對方法調用次數執行分析更強大的工具還是DotTrace,如圖:

?

參考鏈接:

MiniProfiler(MiniProfiler.EF6監控調試MVC5和EF6的性能)?

解決:MiniProfiler.EF出現System.InvalidOperationException”類型的異常在 EntityFramework.dll 中發生

Entity Framework 4.3. Invalid column name 'CreatedOn'

Miniprofiler breaks on missing CreatedOn column

?

轉載于:https://www.cnblogs.com/zeroes/p/miniProfiler.html

與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的使用MiniProfiler跟踪MVC + EF + Bootstrap 2 权限管理系统的性能消耗的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 性av网站 | 国产理论一区 | 91免费版视频 | 日日日人人人 | 特大黑人巨人吊xxxx | 91色视频 | 日日日干干干 | av中文资源在线 | 日日骚av一区二区 | 在线免费观看麻豆 | 日本黄图| 日韩在线观看第一页 | 黄色一级国产 | 一本色道久久综合狠狠躁 | 国产精品区在线观看 | www.日本色| 日本黄网站在线观看 | 国产丝袜自拍 | 51久久久 | 成人自拍视频在线观看 | 99热这里只有精品在线 | 裸体美女免费视频网站 | 日韩视频不卡 | 免费黡色av| 欧美日本一区二区三区 | 成人无码精品1区2区3区免费看 | 一区二区视频免费 | eeuss国产一区二区三区 | 黄色在线视频观看 | 久久丫丫 | 国产乱码精品一区二区三 | 久久伊人精品视频 | 国产欧美日韩综合精品一区 | 人人搞人人| 成人免费观看网址 | 午夜婷婷在线观看 | 午夜精品一区二区三区在线 | 天天干狠狠爱 | 成人动漫在线观看视频 | 欧美日韩一二三区 | 欧美精品久久久久久久多人混战 | 精品一区二区在线观看视频 | 色诱视频在线观看 | 黄色网页入口 | 久草视频福利 | 黄色成人在线网站 | 午夜黄色在线 | 中文字幕在线视频日韩 | 韩国三级丰满少妇高潮 | 欧美 日韩 人妻 高清 中文 | 麻豆视频在线免费看 | 69中国xxxxxxxxx96| 久久人妻少妇嫩草av蜜桃 | 天天射天天爽 | 97在线精品| 日韩欧美国产成人精品免费 | 亚洲精品久久久久久国 | 操操久久 | 超碰在线进入 | 欧美天堂在线 | 久久精品99久久久 | 欧美精品国产 | 人人妻人人澡人人爽精品欧美一区 | 操欧美女人 | 成人精品一区二区三区电影黑人 | 91免费小视频| 久久久久麻豆v国产精华液好用吗 | 国产精选久久久 | 伊人久久中文 | 国产黄色网址在线观看 | 日本丰满少妇一区二区三区 | 国产依人 | 欧美在线看片 | 免费人成在线观看网站 | 国产视频一区二区三区四区五区 | 2021毛片 | 免费久久| 日韩一区二区三区四区在线 | 国产在线网 | 欧美日韩在线二区 | 成人av教育 | 性高潮视频在线观看 | 国产午夜亚洲精品午夜鲁丝片 | 亚洲美女一区 | 国产夜色视频 | 在线免费观看亚洲 | 在线电影一区二区 | 美女免费看片 | 国产精品23p | 久久91精品国产91久久小草 | 四虎精品欧美一区二区免费 | 久久aⅴ国产欧美74aaa | 亚洲专区视频 | 亚洲精品成人无码熟妇在线 | 日本视频免费在线 | 午夜一区在线观看 | 九色福利视频 | 久久精品这里 | 亚洲一区二区三区四区不卡 |