简体   繁体   中英

Increasing Website Performance - ASP.NET

I am working on a .NET website and trying to speed up the loading time. 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. But my question is that after the index calls View() to display the layout, it takes approximately 1.5 seconds to load the layout. 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

Profile the code. The hot code will be obvious.

Or, pause the debugger 10 times under load to see where it stops most. 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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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