title: MinGW C++ vs VS2013 C++, performance difference
body: <p>I am developing a library for power systems simulation, for which the execution time is critical.</p>
  
  <p>I created Netbeans (MinGW) and Visual studio projects.</p>
  
  <p>I compiled the library in both environments and I created a project to run a main.cpp file using the library.</p>
  
  <p>I found that, with the exact same code, the MinGW compiler produces a program that runs about twice as fast than the Visual studio one.</p>
  
  <p>The visual studio one is compiled for 64 bits, while the MinGW is compiled for 32 bits.</p>
  
  <p>Can anydoby explain to me why one is much faster that the other?</p>
  
  <p>PS: the full code can be found at:<a href="https://sourceforge.net/p/fpotencia/code/ci/master/tree/" rel="nofollow">https://sourceforge.net/p/fpotencia/code/ci/master/tree/</a></p>
  
  <p>{EDIT}-----------------</p>
  
  <p>VS output: </p>
  
  <pre><code>1&gt;------ Rebuild All started: Project: fPotencia, Configuration: Debug Win32 ------
  1&gt;  Transformer.cpp
  1&gt;  Solver_ZBlockSubs.cpp
  1&gt;d:\c++\fpotencia\src\solver_zblocksubs.cpp(55): warning C4018: '&lt;' : signed/unsigned mismatch
  1&gt;d:\c++\fpotencia\src\solver_zblocksubs.cpp(59): warning C4018: '&lt;' : signed/unsigned mismatch
  1&gt;d:\c++\fpotencia\src\solver_zblocksubs.cpp(81): warning C4018: '&lt;' : signed/unsigned mismatch
  1&gt;d:\c++\fpotencia\src\solver_zblocksubs.cpp(94): warning C4018: '&lt;' : signed/unsigned mismatch
  1&gt;d:\c++\fpotencia\src\solver_zblocksubs.cpp(121): warning C4018: '&lt;' : signed/unsigned mismatch
  1&gt;d:\c++\fpotencia\src\solver_zblocksubs.cpp(128): warning C4018: '&lt;' : signed/unsigned mismatch
  1&gt;d:\c++\fpotencia\src\solver_zblocksubs.cpp(147): warning C4018: '&lt;' : signed/unsigned mismatch
  1&gt;d:\c++\fpotencia\src\solver_zblocksubs.cpp(165): warning C4018: '&lt;' : signed/unsigned mismatch
  1&gt;d:\c++\fpotencia\src\solver_zblocksubs.cpp(182): warning C4018: '&lt;' : signed/unsigned mismatch
  1&gt;d:\c++\fpotencia\src\solver_zblocksubs.cpp(184): warning C4018: '&lt;' : signed/unsigned mismatch
  1&gt;d:\c++\fpotencia\src\solver_zblocksubs.cpp(211): warning C4018: '&lt;' : signed/unsigned mismatch
  1&gt;  Solution.cpp
  1&gt;  Shunt.cpp
  1&gt;  Load.cpp
  1&gt;  Line.cpp
  1&gt;  Generator.cpp
  1&gt;  ExternalGrid.cpp
  1&gt;  Circuit.cpp
  1&gt;d:\c++\fpotencia\src\circuit.cpp(125): warning C4018: '&lt;' : signed/unsigned mismatch
  1&gt;d:\c++\fpotencia\src\circuit.cpp(132): warning C4018: '&lt;' : signed/unsigned mismatch
  1&gt;d:\c++\fpotencia\src\circuit.cpp(155): warning C4018: '&lt;' : signed/unsigned mismatch
  1&gt;d:\c++\fpotencia\src\circuit.cpp(162): warning C4018: '&lt;' : signed/unsigned mismatch
  1&gt;d:\c++\fpotencia\src\circuit.cpp(460): warning C4018: '&lt;' : signed/unsigned mismatch
  1&gt;d:\c++\fpotencia\src\circuit.cpp(463): warning C4018: '&lt;' : signed/unsigned mismatch
  1&gt;d:\c++\fpotencia\src\circuit.cpp(466): warning C4018: '&lt;' : signed/unsigned mismatch
  1&gt;d:\c++\fpotencia\src\circuit.cpp(469): warning C4018: '&lt;' : signed/unsigned mismatch
  1&gt;d:\c++\fpotencia\src\circuit.cpp(506): warning C4018: '&lt;' : signed/unsigned mismatch
  1&gt;  Bus.cpp
  1&gt;  Generating Code...
  1&gt;d:\c++\fpotencia\src\circuit.cpp(74): warning C4715: 'fPotencia::Circuit::find_bus' : not all control paths return a value
  1&gt;  fPotencia.vcxproj -&gt; D:\C++\fPotencia\Windows\VisualStudio\fPotencia\Debug\fPotencia.lib
  2&gt;------ Rebuild All started: Project: fPotencia_test, Configuration: Debug Win32 ------
  2&gt;  main.cpp
  2&gt;d:\c++\fpotencia\src\test\main.cpp(189): warning C4101: 'k' : unreferenced local variable
  2&gt;  fPotencia_test.vcxproj -&gt; D:\C++\fPotencia\Windows\VisualStudio\fPotencia\Debug\fPotencia_test.exe
  ========== Rebuild All: 2 succeeded, 0 failed, 0 skipped ==========
  </code></pre>
  
  <p>Netbeans output:</p>
  
  <pre><code>"/C/MinGW/MSYS/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
  make.exe[1]: Entering directory `/d/C++/fPotencia/Windows/Netbeans/fPotencia_test'
  "/C/MinGW/MSYS/1.0/bin/make.exe"  -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/fpotencia_test.exe
  make.exe[2]: Entering directory `/d/C++/fPotencia/Windows/Netbeans/fPotencia_test'
  mkdir -p build/Debug/MinGW-Windows/_ext/608944044
  rm -f "build/Debug/MinGW-Windows/_ext/608944044/main.o.d"
  g++    -c -g -I../../../src -I../../../libs -std=c++11 -MMD -MP -MF "build/Debug/MinGW-Windows/_ext/608944044/main.o.d" -o build/Debug/MinGW-Windows/_ext/608944044/main.o ../../../src/test/main.cpp
  mkdir -p dist/Debug/MinGW-Windows
  g++     -o dist/Debug/MinGW-Windows/fpotencia_test build/Debug/MinGW-Windows/_ext/608944044/main.o ../fPotencia/dist/Debug/MinGW-Windows/libfpotencia.a
  make.exe[2]: Leaving directory `/d/C++/fPotencia/Windows/Netbeans/fPotencia_test'
  make.exe[1]: Leaving directory `/d/C++/fPotencia/Windows/Netbeans/fPotencia_test'
  </code></pre>