I just tried out VS2013 Express. It seems to be a lot faster than VS2010 Ultimate(I think).
My only guess would be that the MD5 library is not meant for C++11.
With the same code I got an error about sprintf in the MD5 library (I tried to fix it, but got tired, doesn't really matter). Tried a different library:
http://create.stephan-brumme.com/hash-library/
But that wasn't really the problem either.
I got a bit better results - 21 seconds.
With no clue what to do, I simply started to try to "improve" the code with tips you gave about references and pointers. Couldn't really think of anything useful so I simply created a global char [32] and only changed each letter in the array.
And suddenly I was back where I started - execution time was 10 seconds. Added some threads and success - 8 seconds.
So I guess the problem could be that older gcc versions did really optimize multiple string constructions, newer gcc (or whatever VS uses) doesn't do that for you. That's just my guess.
Anyways, the whole idea of this useless script was to prove my self that I can make a simple webpage in C++ that is faster than PHP.
Assuming that I can strip everything down to bare minimum with C++, I can avoid loading useless modules in memory (what does PHP do).
If anyone still wishes to see the C++ code:
http://pastebin.com/mjn1ziFX
Here is the PHP code too:
http://pastebin.com/a1GWSyhK
C++ execution time (average): 8 seconds
PHP execution time (average): 14 seconds
I know this isn't the best way to test out performance, but just a small project to see why writing in C++ is better.
Thanks for the help!