468,491 Members | 1,962 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,491 developers. It's quick & easy.

C++ Code optimization

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

regards,
Amod

Oct 11 '06 #1
9 3784
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
Oct 11 '06 #2
"Amod" <am********@gmail.comschrieb im Newsbeitrag
news:11**********************@h48g2000cwc.googlegr oups.com...
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
Oct 11 '06 #3
"Amod" <am********@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
: 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

Oct 11 '06 #4
Hello Amod,

On Wed, 11 Oct 2006 05:20:44 UTC, "Amod" <am********@gmail.comwrote:
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
Oct 11 '06 #5
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
Oct 11 '06 #6
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
Oct 11 '06 #7
On 10 Oct 2006 22:20:44 -0700, "Amod" <am********@gmail.comwrote:
>hi all,
Kindly suggest some tips to optimize the C++ code for higher speed.
http://www.tantalon.com/pete.htm
Oct 11 '06 #8
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 =----
Oct 12 '06 #9
Kindly suggest some tips to optimize the C++ code for higher speed.

The following article describes C and C++ optimization techniques:

http://www.eventhelix.com/RealtimeMa...AndCPPCode.htm

--
EventStudio System Designer 2.5 -
http://www.eventhelix.com/EventStudio/
Generate sequence diagrams from text files

Oct 12 '06 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Hagen | last post: by
14 posts views Thread by joshc | last post: by
11 posts views Thread by junky_fellow | last post: by
9 posts views Thread by cyberscout | last post: by
10 posts views Thread by Mike | last post: by
88 posts views Thread by Peter Olcott | last post: by
30 posts views Thread by galiorenye | last post: by
31 posts views Thread by somenath | last post: by
reply views Thread by theflame83 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.