简体   繁体   English

提高网站性能-ASP.NET

[英]Increasing Website Performance - ASP.NET

I am working on a .NET website and trying to speed up the loading time. 我正在.NET网站上工作,并试图加快加载时间。 My problem is that even for the Home Page(not loading any object data) it takes significant amount of time to load the homepage. 我的问题是,即使对于主页(不加载任何对象数据),也要花费大量时间来加载主页。 I have put loggers everywhere to find out whats causing the problem and this is what I have so far: 我到处都有记录器,以找出导致问题的原因,这是我到目前为止的结果:

2016-06-01 12:10:04,217 [5] INFO  - BaseController/SetPrincipal(): Started - 01/06/2016 12:10:04 PM
2016-06-01 12:10:04,235 [5] INFO  - SetPrincipal->PrincipalContextManager(): Started - 01/06/2016 12:10:04 PM
2016-06-01 12:10:04,839 [5] INFO  - PrincipalContextManager() finished: 00:00:00.6040604

2016-06-01 12:10:04,990 [5] INFO  - SetPrincipal->DILAuthorizationContext(): Started - 01/06/2016 12:10:04 PM
2016-06-01 12:10:06,657 [5] INFO  - DILAuthorizationContext() finished: 00:00:01.6661666

2016-06-01 12:10:06,659 [5] INFO  - GetRoles->PrincipalContextManager(): Started - 01/06/2016 12:10:06 PM
2016-06-01 12:10:06,822 [5] INFO  - PrincipalContextManager() finished: 00:00:00.1630163

2016-06-01 12:10:06,954 [5] INFO  - BaseController/SetPrincipal() finished: 00:00:02.8402840

2016-06-01 12:10:07,026 [5] INFO  - HomePageController/Index: Started - 01/06/2016 12:10:07 PM
2016-06-01 12:10:07,091 [5] INFO  - HomePageController/Index finished: 00:00:00.0650065

2016-06-01 12:10:08,312 [5] INFO  - Loading Layout Start: 01/06/2016 12:10:08 PM
2016-06-01 12:10:08,314 [5] INFO  - Loading Layout Finish: 01/06/2016 12:10:08 PM
2016-06-01 12:10:08,711 [5] INFO  - Requesting JS bundles: 01/06/2016 12:10:08 PM
2016-06-01 12:10:09,482 [5] INFO  - Requesting JS bundles: 01/06/2016 12:10:09 PM

2016-06-01 12:10:09,658 [5] INFO  - Layout CanView Users Started: 01/06/2016 12:10:09 PM
2016-06-01 12:10:09,770 [5] INFO  - Layout CanView Users Finished: 01/06/2016 12:10:09 PM

I'm aware that I have to use min files for the bundles and tweak the SetPrincipal method to speed it up. 我知道我必须为捆绑包使用min文件,并调整SetPrincipal方法以加快速度。 But my question is that after the index calls View() to display the layout, it takes approximately 1.5 seconds to load the layout. 但是我的问题是,在索引调用View()以显示布局之后,加载布局大约需要1.5秒。 How can I find out whats causing this delay? 我如何找出造成此延迟的原因? Any help is appreciate! 任何帮助,感激不尽! Thanks :) 谢谢 :)

Update: I guess I will mark usr's solution as the answer as thats the only solution recommended so far but I'd really appreciate if you guys can recommend anything else 更新:我想我会将usr的解决方案标记为答案,因为那是到目前为止唯一推荐的解决方案,但是如果你们能推荐其他任何方法,我将不胜感激

Profile the code. 分析代码。 The hot code will be obvious. 热门代码将显而易见。

Or, pause the debugger 10 times under load to see where it stops most. 或者,在负载下将调试器暂停10次,以查看调试器在何处停止。 That's the code that consumes most time. 那是消耗大部分时间的代码。

This technique is called the poor man's profiler by the way. 顺便说一下,这种技术被称为穷人的剖析器 I often prefer it to an actual profiler because I can inspect the app state in the debugger. 我经常喜欢它而不是实际的探查器,因为我可以在调试器中检查应用程序状态。 Pro tip: Run parallel load and use the parallel stacks window. 专家提示:运行并行加载并使用并行堆栈窗口。 That way you get a sample of N threads presented as a tree! 这样一来,您将获得一个以树形式显示的N个线程的样本!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM