473,503 Members | 6,385 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C++ Code optimization

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

regards,
Amod

Oct 11 '06 #1
9 4082
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3310
by: PWalker | last post by:
Hi, I have written code that I would like to optimize. I need to push it to the limit interms of speed as the accuracy of results are proportional to runtime. First off, would anyone know any...
8
1933
by: Hagen | last post by:
Hi, I have a question that you probably shouldn´t worry about since the compiler cares for it, but anyways: When you run your compiler with optimization turned on (eg. g++ with -Ox flag) and...
14
3104
by: joshc | last post by:
I'm writing some C to be used in an embedded environment and the code needs to be optimized. I have a question about optimizing compilers in general. I'm using GCC for the workstation and Diab...
11
1798
by: junky_fellow | last post by:
What are the basic guidelines to write an optimised code. What points should one keep in mind for this ? Is this purely architecture or complier specific ? Are there any general techniques that...
9
1549
by: cyberscout | last post by:
OK I have some code which I didn't write and I'm toying with whether I need to tidy it up. In the code is the line shown in Example 1 Exampe 1: sprintf(stringvariable, "%s", "String"); ...
24
8565
by: Kunal | last post by:
Hello, I need help in removing if ..else conditions inside for loops. I have used the following method but I am not sure whether it has actually helped. Below is an example to illustrate what I...
10
2126
by: Mike | last post by:
Is it still true that the managed C++ compiler will produce much better opimizations than the C# compiler, or have some of the more global/aggressive opimizations been rolled into the 2005...
88
7950
by: Peter Olcott | last post by:
Cab you write code directly in the Common Intermediate language? I need to optimize a critical real-time function.
30
3472
by: galiorenye | last post by:
Hi, Given this code: A** ppA = new A*; A *pA = NULL; for(int i = 0; i < 10; ++i) { pA = ppA; //do something with pA
31
2224
by: somenath | last post by:
Hi All, I was going through one of the exercise of one C tutorial . In that they have given one small code and asked about the output. #include <stdio.h> int main(void) { int x =...
0
7194
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7070
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6976
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4993
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
729
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.