I'm experiencing a strange phenomenon when switching between the Visual C++ (using Windows Vista) and the gcc compiler (using Ubuntu Linux or Cygwin). I've written a console application which transforms pretty large pointer based structures within memory. The source code can be compiled with both compilers without any problems. There is mainly only one header file which takes care of the compiler differences (see attachment). In this file I define hashmaps which the program heavily relies on (for one example input they had to manage nearly one million entries).
But what makes me wondering is the fact that the runtime and memory consumption of the same program heavily differ depending on the compiler used:
VC++ compiler and Windows Vista: runtime is approximately 2 minutes and 20 seconds; peak memory consumption is approximately at 1800 MB RAM
Gcc compiler and Ubuntu Linux resp. Cygwin: runtime is approximately 20 minutes; peak memory consumption is approximately at 1350 MB RAM
Do you have any idea what could lead to these performance differences in the two scenarios? Is it a common observation that the gcc compiler performs that bad regarding runtime? Should I use different data structures with gcc to gain more performance? I would really appreciate any help.
You failed to mention the compiler switches that you are using on each platform. Check that they are the same. C++ optimization makes all the difference... expecially with heavy memory operations.
By the way, I agree with the previous reply. Pass strings by reference if/when possible.
VC++ compiler and Windows Vista: runtime is approximately 2 minutes and 20 seconds; peak memory consumption is approximately at 1800 MB RAM
Gcc compiler and Ubuntu Linux resp. Cygwin: runtime is approximately 20 minutes; peak memory consumption is approximately at 1350 MB RAM
Compiler options used?
Do you have any idea what could lead to these performance differences in the two scenarios?
Anything from bad programming to timing unoptimized code. So how are we to know what it could be, given that range of possibilities? Show us the code (and no, a header file is not enough. We need to see what you're doing).
Should I use different data structures with gcc to gain more performance?
Without more information no one can answer your question.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.