CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2009
    Posts
    1

    Strange phenomenon when switching compilers

    Dear experts,

    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.

    Thank you very much in advance.

    Roy
    Attached Files Attached Files

  2. #2
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Strange phenomenon when switching compilers

    >> size_t operator() (const std::string &s) const
    >> bool operator()(const std::string &s1, const std::string &s2) const

    A good start would be to pass those strings by reference.

    gg

  3. #3
    Join Date
    Jan 2009
    Posts
    28

    Re: Strange phenomenon when switching compilers

    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.

    Best Wishes,
    -David Delaune

  4. #4
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Strange phenomenon when switching compilers

    Quote Originally Posted by royem View Post
    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.

    Regards,

    Paul McKenzie

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured