Performance profiling in Visual Studio under Virtual Machine (Sampling VS Instrumentation)
The bad news is that Visual Studio’s own, excellent Performance Profiler does not support Sampling under any virtual machine environment – only Instrumentation.
It will not fail, but will not be able to collect any performance data if you try to do sampling while running in a virtual machine (like Parallels Desktop or VMWare Player / Workstation).
|Visual Studio - Branch Mispredition with Sampling|
On the other hand, instrumentations needs a special build, it basically injects data collection functions into your compiled code. Hence the runtime performance of the instrumented code is generally a magnitude (10x) slower than with Sampling and not detailed at all: only function level, and it only measures the time spent in each function. For instance, if you are writing a multi-threaded app, it is likely that you will spend some time in Thread.Sleep to synchronize your threads. This is idle time for the CPU so sampling does not really care, but it will be the biggest “problem” according to the Instrumentation - which can be really misleading.
So, if you want to measure performance, boot directly into Windows rather than any virtual machine.