C/C++
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives FAQs C/C++

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old July 29th, 2008, 02:39 PM
Gordon Burditt
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Which is faster?

>Which is faster? Post Increment or assignment? Why?

Given two tasks, A and B, the C standard does not guarantee anything
about the relative speed of the two, even if B is "repeat A one
billion times". The result is also likely to depend on the instruction
set of the target machine, and the optimization settings of this
invocation of the compiler.

In the case of post increment vs. assignment, it does matter
whether the resulting value is used. The code for:
p++;
vs.
p += 1;
is hopefully identical. However, identical code does not guarantee
identical performance, as the prior state of the cache and execution
state of the processor may change that time.

>I was not able to get any things.


Those things belong to someone else, and scams with Paypal do
not entitle you to take them.


Reply With Quote
  #2  
Old July 31st, 2008, 06:00 PM
Gordon Burditt
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Which is faster?

>In the case of post increment vs. assignment, it does matter
>whether the resulting value is used. The code for:
>p++;
>vs.
>p += 1;
>is hopefully identical.
>
>That's horribly misleading. I'd expect the compiler to generate
>identical code for 'p += 1' and '++p', NT 'p++'. In fact, if the


See those semicolons? They are in there for a reason.
You can't use the value of p++; , an expression like foo(p++;)
won't compile.

>resulting value is used, the generated code HAS to be different
>for 'p++' and 'p += 1'.


Please explain how you can use the value with the semicolons left in.


Reply With Quote
Reply

Viewing: Web Development Archives FAQs C/C++ > Which is faster?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek