Application runs faster with visual studio performance analysis

I found the answer:

The reason is because when you run your application within Visual Studio, the debugger is attached to it. When you run it using the profiler, the debugger is not attached.

If you try running the .exe by itself, or running the program through the IDE with "Debug > Start Without Debugging" (or just press Ctrl+F5) the application should run as fast as it does with the profiler.

https://stackoverflow.com/a/6629040/1563172

I didn't find it earlier because I thought that the reason is concurrency.


Since you are using threading in your program, the Windows timer resolution can also be a reason.

Default windows timer resolution is 15.6ms

When you run your application with the profiler, this is reduced to 1ms causing your application to run faster. Checkout this answer