I've wrote an algorithm for threaded IntroSort. I use winapi for threading.
I've developed it using CodeBlocks and it's pretty fast, but when I take the same source code and compile it in VisualStudio Express 2013 it executes nearly 4 times slower. I've tested it and it doesn't have anything to do with threading, the program simply runs 4 times slower for any number of threads I give them.
What is going on here? How come visual studio's programs are so slow?
> VisualStudio Express 2013 it executes nearly 4 times slower.
Depends on the specific code really; each compiler (optimiser) has its own strengths and weaknesses. On an average, my experience is that the Microsoft compiler generates code that is about 30 to 50 percent slower than the GNU compiler. While there is not much of a difference between the LLVM and GNU compilers.
If optimisations were turned on in both builds, it is possible that your code hit the sweet spot of the GNU optimiser, and the weaknesses of the Microsoft one.
It is quite easy to write code that addresses the strengths of one implementation and the weaknesses of another.
For instance, if I wanted to showcase LLVM, and show GNU as well below par and Microsoft as poor, I could write:
Yea, that example has very different execution times, but you used a lot of library calls there.
My program, besides the call to CreateThread (from windows.h, which isn't called many times) is all hand written code, just loops and recursion. Besides that I've already used registers to store some often used variables, so I don't see how any optimization could have noticeable effects.
I've tried the release mode with no differences.