C++ Code optimization

Discussion in 'C++' started by Amod, Oct 11, 2006.

  1. Amod

    Amod Guest

    hi all,
    Kindly suggest some tips to optimize the C++ code for higher speed.

    regards,
    Amod
     
    Amod, Oct 11, 2006
    #1
    1. Advertising

  2. Amod

    benben Guest

    Amod wrote:
    > hi all,
    > Kindly suggest some tips to optimize the C++ code for higher speed.
    >
    > regards,
    > Amod
    >


    Don't confuse the compiler it'll do the optimization for ye.

    Regards,
    Ben
     
    benben, Oct 11, 2006
    #2
    1. Advertising

  3. Amod

    Heinz Ozwirk Guest

    "Amod" <> schrieb im Newsbeitrag
    news:...
    > hi all,
    > Kindly suggest some tips to optimize the C++ code for higher speed.


    Don't do it until your program is completed. If it turns out, that it is
    really too slow, find out which part of the program really is the
    bottleneck. Don't guess, but measure the speed of the various parts of the
    program. Once you know where the program spends most of its time, you might
    find out how to improve that part or ask others about it. But remember to
    repeat your tests for each compiler you will be using in the future, even
    for each future version of your current compiler, for each (version of) OS
    and even for different hardware.

    And don't forget the guy, who was very proud that he improved a loop, where
    his program spent more than 90% of its time, only to find out that it was
    the system's idle loop.

    Heinz
     
    Heinz Ozwirk, Oct 11, 2006
    #3
  4. "Amod" <> wrote in message
    news:...
    : Kindly suggest some tips to optimize the C++ code for higher speed.

    Optimization is more about (application-specific) algorithms
    than about line-by-line code tuning.

    Of course there are some general advice, like avoiding unnecessary
    object copies, calling reserve() on a vector, etc.

    Why don't you post a code segment, or describe an algorithm, whose
    performance is critical for your application ?
    This would allow the group to give you concrete advice.


    hth -Ivan
    --
    http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
    Brainbench MVP for C++ <> http://www.brainbench.com
     
    Ivan Vecerina, Oct 11, 2006
    #4
  5. Amod

    David Guest

    Hello Amod,

    On Wed, 11 Oct 2006 05:20:44 UTC, "Amod" <> wrote:

    > hi all,
    > Kindly suggest some tips to optimize the C++ code for higher speed.
    >
    > regards,
    > Amod
    >


    Also consider the choices make as you program. Sometimes we know
    where bottlenecks may be and other tmes they appear in suprising
    places. You'll have to know your tools and measure its performance.
    This is usually done after the fact since it is difficult to
    gauge the performance of something that doesn't exist. There are
    exceptions though.

    Consider a large sort or data extraction problem. For small data
    sets the method might not be very important as it doesn't affect
    the speed that much. Larger data sets we often do need to worry.
    You need to choose the right solution for a problem. Communcations
    are another good example where how you choose to have products
    talk to one another can make a huge difference.

    Please remember that speed is often not enough. Correct comes
    first. There are some problems where an exact predictable answer
    is not needed, but hopefully you know when those methods can be
    used.

    David
     
    David, Oct 11, 2006
    #5
  6. Amod

    Kevin Handy Guest

    Amod wrote:
    > hi all,
    > Kindly suggest some tips to optimize the C++ code for higher speed.
    >
    > regards,
    > Amod
    >

    Number 1 rule: Don't
    Number 2 rule: Don't, yet.

    ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
     
    Kevin Handy, Oct 11, 2006
    #6
  7. Amod posted:

    > hi all,
    > Kindly suggest some tips to optimize the C++ code for higher speed.



    Simplest thing to do is bring your laptop on the train -- that way all
    programs will run at least 150km/h faster.

    --

    Frederick Gotham
     
    Frederick Gotham, Oct 11, 2006
    #7
  8. benben posted:

    >> Kindly suggest some tips to optimize the C++ code for higher speed.

    >
    > Don't confuse the compiler it'll do the optimization for ye.



    I thought that was how you DEoptimise code?

    --

    Frederick Gotham
     
    Frederick Gotham, Oct 11, 2006
    #8
  9. On 10 Oct 2006 22:20:44 -0700, "Amod" <> wrote:
    >hi all,
    >Kindly suggest some tips to optimize the C++ code for higher speed.


    http://www.tantalon.com/pete.htm
     
    Roland Pibinger, Oct 11, 2006
    #9
  10. EventHelix.com, Oct 12, 2006
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pete Wright

    Re: Code optimization...

    Pete Wright, Jul 5, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    396
    David Waz...
    Jul 6, 2003
  2. Russell Wallace
    Replies:
    7
    Views:
    415
    Russell Wallace
    Jun 11, 2004
  3. ashu

    optimization of vhdl code

    ashu, May 8, 2006, in forum: VHDL
    Replies:
    5
    Views:
    4,103
  4. joshc
    Replies:
    14
    Views:
    804
    Keith Thompson
    Jan 14, 2005
  5. Ravikiran

    Zero Optimization and Sign Optimization???

    Ravikiran, Nov 17, 2008, in forum: C Programming
    Replies:
    22
    Views:
    903
    Thad Smith
    Nov 24, 2008
Loading...

Share This Page