I did some benchmarking using my program (a chess engine), using its own benchmarking function (search 100 randomly pre-selected positions to a fixed depth, completely deterministic). Every "run" is run twice, and higher of the 2 taken (differences between runs were all within 1%). The numbers are Mnps (million nodes per second) searched. Higher the better.
I used 4 compilers - MSVC 9 64-bit, MSVC 9 32-bit, GCC 4.4.0 SVN 64-bit, GCC 4.2.1 32-bit.
For MSVC, I adopted relevant (optimization-related) options from the list Elysia posted.
The program does a lot of low level twiddling with 64-bit integers (called bitboards in computer chess), and is heavily recursive.
All the tests are run inside a VMware virtual machine running 64-bit XP Pro. Host is 64-bit Linux.
64-bit MinGW is my own build of GCC with mingw-w64 -
http://sourceforge.net/forum/forum.p...orum_id=723797
Code:
MSVC 64-bit
Microsoft (R) C/C++ Optimizing Compiler Version 15.00.21022.08 for x64
no optimization -
0.486265
/Ox -
1.52933
/Ox /Ob2 /Oi /Oy (Elysia's suggestion) -
1.55582
Code:
MSVC 32-bit
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08 for 80x86
no optimization -
0.392031
/Ox -
0.953033
/Ox /Ob2 /Oi /Oy (Elysia's suggestion) -
0.951351
Code:
GCC (MinGW 64-bit)
gcc version 4.4.0 20081101 (experimental) (GCC)
-O3 -
1.74929
-O3 -march=native -
1.76843
Code:
GCC (MinGW 32-bit)
gcc version 4.2.1-dw2 (mingw32-2)
no optimization -
0.405505
-O3 -
1.04415
-O3 -march=native -
1.01338
For (unfair) comparison, on the Linux host, I get 2.585 Mnps. Didn't think virtualization would matter this much since this program is quite CPU-intensive.
As it appears, gcc 4.2.1 was only slightly (6%) faster than MSVC (both 32-bit), but gcc 4.4.0 SVN was quite a bit (14%) faster than MSVC (both 64-bits). Guess GCC people haven't been slacking off . But I think even GCC 4.2.1 was released after MSVC 9, and GCC 4.4.0 is not even released yet. Too bad we can't get MSVC SVN.
BTW, does MSVC have something like "-march" for GCC (optimize for a specific target)? I can't seem to find it in the documentation.