I had issues with debugging some very complex integration test in our application. The test involves setting environment, deploying database and tested code uses a lot of database queries with NHibernate, Spring.NET (DI, AoP, transactions, …), multithreading and some network activity when communicating with integration platform (includes calls to native dlls).
I have two systems where I work with the same code base:
Notebook
- i7 (2 cores with HT = 4 logical CPUs), 4GB RAM, 5400 rpm disk, Win 7 64bit
Virtual machine (Oracle Virtual Box)
- Host: i7 (4 cores with HT = 8 logical CPUs, 12 GB RAM, system runs from SSD, virtual machine from 7200 rpm disk, Win 7 64bit)
- Virtual machine: 4 cores assigned, 8 GB RAM assigned, Win 2008 R2 Enterprise (64 bit)
- VPN for network communication
- No other virtual machine runs on the host
Now if I run the test without debugging the execution time is almost the same 12-15s (so network communication should not be the issue) but if I run the test with debugging it takes less then 2 minutes on notebook but more then 4 minutes on the virtual machine (I need to debug some code at very end of the test). I would expect that virtual machine will perform better then notebook but it is more then two times slower!
The test code uses NUnit, Spring.NET test base classes and it runs from VS 2010 Ultimate + Resharper test session.
It is proof of concept code so unit test coverage was quite low. I wrote some additional unit tests to test as much code as possible separately but still some parts are not written in the way they would be easy to cover with unit tests.
Side note: the point of this proof-of-concept is among others identify these parts for further refactoring, not to refactor the code now.
What can cause the speed difference?
Edit:
When I was writing this question I thought about other reason not related to programming itself – I put separate question on SuperUser.
The problem was probably caused by anitivirus on the host machine. I made exceptions from scanning for virtual disks as described in linked SuperUser question and performance was improved.
Another performance boost was using attaching to debugger on demand by using Debugger class (just for fixing issues) instead of running whole test attached to debugger.