Speeding up compilation and unit testing in Visual Studio 2010 / Resharper / ASP.NET MVC
I'm working on a medium sized ASP.NET MVC solution with Visual Studio 2010 and Resharper. The project was blazing fast when I started developing it 1 1/2 years ago, but over time it has become slower - not only compilation, but also the time it takes ASP.NET to re-initialize the website. Since I am practicing TDD and refactoring quite often, I frequently need to recompile an re-run my tests, so I am looking for ways to mitigate this if any possible.
The problem in detail
It takes me about 20-25 seconds from starting to recompile the project to being able to view the result in a web browser.
Running a single unit test (just a single test, not the entire suite) with the Resharper test runner is also very slow (about 15-20 seconds). For some weird reason it seems that Resharper takes most of the time initializing the test run and spends only a very small fraction actually running the test.
What I've already done:
- Replaced my hard drive with an SSD (huge impact)
- Moved ASP.NET's compilation and the Windows Temp directory dir to SSD-like (hardware) RAM drive (big impact, but that was before SSD)
- Disabled automatic compilation of one project I rarely modify (Small impact since that project is small anyway).
- Weeded out unnecessary references to .NET and third party libraries (very small impact, if any)
- Some black magic tricks discussed in this blog post. (very small impact, if any).
Yet I am still stuck with the (slow?) figures above and I feel that this is harming my productivity. Now I am wondering what do do next.
My current system setup:
- Core 2 Quad Q6600 CPU
- 4GB DDR2开发者_开发技巧 800 RAM
- 120 GB SSD
- Windows 7 x64
- Visual Studio 2010 Ultimate with Resharper 5.5
My solution's specs:
- 22.000 Lines of .NET 4 C# Code
- 3 projects: One ASP.NET MVC, one test project , one tiny general purpose library is included by the other two and which I do not compile unless something changed.
- 35 references to other libraries (.NET framework and open source stuff)
- ~200 Views
- 850 Unit Tests
Now my questions:
- Would upgrading my RAM to 8GB could give me a significant performance boost?
- Are these figures normal? Or perhaps this could be a problem with my solution?
- What would you try next (apart from buying an entirely new computer)?
Thanks,
Adrian
Edit: One particularly weird thing is that when I hit the "build solution" button, Visual Studio spends about 8 seconds showing me a waiting symbol until it actually starts compiling and the compilation window is being updated. The IDE is unrespsonsive during this period. Thats a good portion of the actual compilation time. I wonder what Visual Studio is doing during this period?
For that size solution, it really seems that your hardware is ok and should be fast enough to build-test. What I've found is that most of the build performance problems (in my case anyway) are related to project dependencies and not to actual compile time. I couple of ideas to help you find out the problem:
try turning the "MSBuild project build output verbosity" to "Diagnostic" (Options->Projects and Solutions->Build and Run), also install the VSCommands extensions (it contains a build statistics extension that shows time taken on each step) and check what is the part that is talking up the most time.
Are the dependencies on other projects (the 35 you refer to) in the GAC, or are they scatter through your HD? Are they auto-refresh references (do they have .refresh file underneath them). Maay try to simplify the resolution of these dependencies, ie copy local all the DLLs to the bin directory and see if it helps
You can try the secret Resharper.Internal feature "Concurrent building with MSBuild" as described here.
Since this is an MVC project, ensure your project's "Build Views" is off.
- Right Click Project File -> Unload Project on your MVC project
- Right click Project File -> Edit Project
- Check setting... false
- Save and Right Click -> reload project.
I leave it on so that the compiler finds my mistakes before my customers do. But Build Views is horribly slow.
I had a similar problem. Since I hit the 'Run tests'
button it took a minute or so to have the test running.
My problem was that I had the test settings pointing to 'Trace and Impact'
instead of 'Local'
.
To select test settings, go to 'Test'
menu and then 'Select Active Test Settings > Local'
.
That worked for me.
You can setup a build server which will run:
- Build
- Tests
- Deployment
You'll have to wait roughly the same amount of time to see the new version go live, but it won't consume your development PC resources.
Similar problem here, I'd left 'code coverage' turned on.
精彩评论