EDIT 1
I do not exclude at all this might be caused by something very basic side effect of using the Profiler (some faulty setting in my \"regular\" pro
If you are using threads within your code, the windows timer resolution is also a reason for this.
Default windows timer resolution is 15.6ms
When you run your application with the profiler, this is set to 1ms and the application runs faster. Checkout this answer
Running with the debugger disables jit optimizations. If you run the exe normally jit optimizations will be enabled. Attaching a debugger to such a running application allows you to debug it with enabled optimizations.
Release-Build vs Debug-Build has two consequences:
I've come across this many times... There is a very simple explanation for it. The profiler doesn't dispose objects, so the cost of object-disposal is not incurred while profiling.
Thus, if you want to improve performance to make it match the profiled performance, figure out where you're instantiating all these short-lived objects, and refactor the code.
I don't yet know of a really great way to immediately find the offending code, but I can help you narrow it down. If you profile your code, open the report, select "Functions" as your Current View, and then sort by Inclusive Samples, you will see the top methods... Your performance problem with object-instantiations is likely to be in one of those methods with the most Inclusive Samples.
Considering that the question is about code running faster under the profiler, and that the specific questions are "1. WHAT EXACTLY HAPPENS, HOW, and WHY ? and 2. How to make my code behave like that natively ?" the accepted answer is wrong, since it does not address the profiler at all, nor does it mention the specific cause of the 20x speed up.
What exactly happens is this:
In the "Debug" tab of your project properties the "Enable unmanaged code debugging" check box is checked; this option causes the debugger to be slow as molasses.
When you run the profiler, it is still the debug version of your program which you are profiling, so the "DEBUG" symbol is defined, and all the tracing, assertions, etc. are enabled, but the debugger is not involved, so the "Enable unmanaged code debugging" option is not applicable. (JIT optimizations are probably enabled while profiling, but that would not account for even a 2x performance boost, let alone a 20x boost.)
If you want to enjoy this 20x boost while debugging your code, (not only while profiling,) go to the "Debug" tab of your project properties and make sure that "Enable unmanaged code debugging" is unchecked.
P.S.
There is a question which is a few-month-older duplicate of this one: How Come when I sampling profile a program and it actually runs faster than not profiling?