Here's a list of things that may slow down execution under a debugger. I've seen a few threads go by about ways that running under the debugger significantly slows down normal execution by more than 2x, and this is a collection of those items.
Background:Stepping through each statement (F10) runs significantly slower than just running the code under a debugger (F5) (some perf numbers here). But just running code F5 under a debugger can run at full speed. For example running pure jitted code that doesn't do anything a debugger needs to know about (like loading types or throwing an exception) ought to be run at full speed. So this loop should not slow down merely because it's under the debugger:
for(int i =0; i < 10000; i++);
Certain operations become slower under a debugger. For example, if the app generates debug events (like exceptions or loading types), it will slow down to communicate with the debugger. The debugger can also twiddle knobs to slow the debuggee down (such as disabling optimizations). So the debugger slowdown depends on what the code can do, and what the debugger does.
List: Here's a list of things that may significantly slow down normal F5 execution under a debugger. This is mainly targetted at managed-debugging, but much applies to native as well:
I'll come back and update this list as I think of more thing.