EDIT 1
I do not exclude at all that this may be caused by something very significant side-effect of using Profiler (some erroneous settings in my "normal" project)
I wanted to improve the computing time in my application, so I decided to go through a thorough profiling analysis. So, I just started profiling the .Net memory allocation to analyze my application.
I was completely stunned to watch the calculations x20 times faster !
The application consists of reading data from binary files using BackgroundWorkers, processing them, storing and storing the results in the MSSQL database. Each round usually takes 20 seconds, and when profiling it takes only 1 second. I checked and made sure that the results in both cases are coherent.
An expert .Net friend told me that the profiler optimizes threads and "somehow" finds its way through Locks threads and bottlenecks, but I just can't believe it.
So my questions are:
- WHAT EXACTLY WILL HAPPEN, HOW AND WHY?
- How to make my code behave like this?
EDIT 2
I KNOW , that sounds crazy and incredible. I myself am still very suspicious. But this is TRUE.
The same code works very fast when the profiler starts. I use EXACT test data and watch SUCH EXIT. I cannot give a simple reproduction project, since it is a relatively large structure. I am using Visual Studio 2010 Profiler.
I will tell you as much as possible about the stream and be sure to publish the key as soon as I find it.
Regular RUN logs:
03/23/2011 18:04:34 | 180434.621 | SIMULATING SET [5] - [1] - [5 PC-1 0 [SET 1/48]
03/23/2011 18:05:01 | 180501,271 | PROCESSING TIME: 00: 00: 26.6515244
etc..
Run LOGS profiler:
03/24/2011 11:38:15 | 113815,592 | SIMULATING SET [5] - [1] - [5 PC-1 0 [SET 1/48]
03/04/2011 11:38:17 | 113817.350 | PROCESSING TIME: 00: 00: 01.7581005
etc..
EDIT 3: Key
Ok, OK, my TROUBLE (I warned about this possibility when editing 1, because it was too unbelievable. Sorry) @Watts suggested checking if I was in debug or release mode. What i have already done. BUT @SnowBear pointed out that there are two different things: launch the debug version of the software and run the software under the debugger. I made sure that the active RELEASE configuration in Build and Execution is VS2010. However, since I was just starting out crazy, I decided to start the application directly from the exe file in bin / release. And voila ... the processes took 1 second each. Starting Profiler will bring you into debug mode (regardless of whether you are in debug or debug mode), which is confusing me.
Thanks to the closed case.
Mehdi LAMRANI
source share