473,509 Members | 2,946 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Faster for() loops?

Neo
Hi Folks,http://www.abarnett.demon.co.uk/tutorial.html#FASTFOR Page
states:for( i=0; i<10; i++){ ... }i loops through the values
0,1,2,3,4,5,6,7,8,9 If you don't care about the order of the loop counter,
you can do this instead: for( i=10; i--; ) { ... }Using this code, i loops
through the values 9,8,7,6,5,4,3,2,1,0, and the loop should be faster. This
works because it is quicker to process "i--" as the test condition, which
says "is i non-zero? If so, decrement it and continue.". For the original
code, the processor has to calculate "subtract i from 10. Is the result
non-zero? if so, increment i and continue.". In tight loops, this make a
considerable difference.
How far it holds true.. in the light of modern optimizing compilers? and
will it make a significant difference in case of embedded systems???

Thanks,
-Neo
"Do U really think, what U think real is really real?"
Nov 15 '05
109 4164
Personally, sometimes I like top.......

Lanarcam wrote:
Paul Marciano wrote:
Robert Scott wrote:
It amazes me how some people can claim to speak for the whole group
with no documentation at all. I, for one, appreciate top-posting when
it is appropriate.

(snip)
But now it appears it's something so small - the order of text within a
message. My God... how anal some people are. Ok, that's unfair, but
only just.


(snip)
You know, people are clever. They can figure out messages. I don't
see how your personal quests do anything but make you feel important.
I don't know. This thread amazes me. It simply amazes me.

Gulliver would perhaps have called that the battle of
top postians vs bottom postians ;)

and sometimes I like bottom....(also in posting too... (are smilies
allowed? :) ....))
Wow, with all the other issues there are in this forum to discuss, I
can't believe how anal some ppl are....sheesh!
John
Nov 15 '05 #101


Steve at fivetrees wrote:
"Default User" <de***********@yahoo.com> wrote in message
news:3q************@individual.net...
Steve at fivetrees wrote:

"Mark McIntyre" <ma**********@spamcop.net> wrote in message
news:84********************************@4ax.com ...

On Wed, 28 Sep 2005 03:29:35 +0100, in comp.lang.c , "Joe Butler"
<ff***********@hotmail-spammers-paradise.com> wrote:
>To Flash and Walter,

Are you clinically thick? You're still top posting. In CLC thats the
height of rudeness. Stop it.

Who gives a shit? Why insult people over a minor matter of protocol?
Sheesh!


Don't disrespect our group wishes.

Oh, so calling someone "clinically thick" over something so trivial is
somehow respectful?

Show some respect for others. *Then* you'd be entitled to talk to me on the
subject.

Steve
http://www.fivetrees.com


You know, most mail clients have a setting to top or bottom post on
replies. Conformance to the guidelines is something that should be
considered if one wants to be a 'good citizen,' (IMO, that what makes
ppl civilized) unless of course you get some satisfaction by giving anal
retentive ppl high blood pressure and even more, instill in them even
further need for their crusade. I especially like it when they berate
ppl for a miscue of non-conformance. Was it because they got sand
kicked in their face when they were in first grade and they made it the
lifes work to 'exercise power' over ppl? Wow, some ppl really need to
get a life. lol
John
Nov 15 '05 #102
John Hudak wrote:

I especially like it when they
berate ppl for a miscue of non-conformance. Was it because they got
sand kicked in their face when they were in first grade and they made
it the lifes work to 'exercise power' over ppl? Wow, some ppl really
need to get a life. lol John

Another idiot for the bozo bin. Man, comp.arch.embedded is coming off
WAY worse than I would have expected. Starting to think about just
filtering out X-posts to that group.
Brian
Nov 15 '05 #103
John Hudak wrote:
OTOH, if you are in the $10 retail produce area then
saving $0.20 over the next processor in the line may be worth all the
extra engineering time. Somehow, after living thought many sides of
this problem, throwing hardware at it is usually the best approach. Just
a personal opinion from experience, your mileage and situation may
vary..... John


I think this is a very personal experience related thing. My experience for
example it the opposite of yours. I developed cost sensitive high volume
products for nearly 20 years and not once was throwing hardare at it a
viable solution. We used C twice and both times had to go in and make
significant changes to reduce code size. However, this was not so much the
fault of C itself or the compilers, we had assumed software engineers from
another department who were 'brought up' on C were capable of writing space
efficient code. Thereafter we wrote everything in assembler.

At one million units, a saving of 20 cents is $200K. That buys a lot of
engineering time.

Ian

Nov 15 '05 #104
"Default User" <de***********@yahoo.com> wrote in message
news:3q************@individual.net...

Another idiot for the bozo bin. Man, comp.arch.embedded is coming off
WAY worse than I would have expected. Starting to think about just
filtering out X-posts to that group.


<plonk>

Get your priorities straight, friend.

Steve
http://www.fivetrees.com
Nov 15 '05 #105
Steve at fivetrees wrote:
"Default User" <de***********@yahoo.com> wrote in message
news:3q************@individual.net...
Another idiot for the bozo bin. Man, comp.arch.embedded is coming off
WAY worse than I would have expected. Starting to think about just
filtering out X-posts to that group.

<plonk>

Get your priorities straight, friend.

This is the thread that never ends, it just goes on and on my friends!
Some people started posting to it, not knowing what it was, and they'll
be posting forever just because...

Sorry. Last post, promised. :-)

S.
Nov 15 '05 #106
In article <43***********************@news.zen.co.uk>,
Joe Butler <ff***********@hotmail-spammers-paradise.com> wrote:
To Flash and Walter,

Maybe 10% saved for a 1k memory was a bit of an exageration on my part.


<SNIP>

You don't get it, eh. Nobody knowledgable is reading this.
Last message before plonk.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.



Groetjes Albert

--
--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- like all pyramid schemes -- ultimately falters.
al****@spenarnc.xs4all.nl http://home.hccnet.nl/a.w.m.van.der.horst
Nov 15 '05 #107
I think you don't get it.
You are an anal retent.

You'll find this on the google archives, I'm sure.
Otherwise, why bother to make the post, plonker.
"Albert van der Horst" <al****@spenarnc.xs4all.nl> wrote in message
news:in********@spenarnc.xs4all.nl...
In article <43***********************@news.zen.co.uk>,
Joe Butler <ff***********@hotmail-spammers-paradise.com> wrote:
To Flash and Walter,

Maybe 10% saved for a 1k memory was a bit of an exageration on my part.


<SNIP>

You don't get it, eh. Nobody knowledgable is reading this.
Last message before plonk.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.



Groetjes Albert

--
--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- like all pyramid schemes -- ultimately falters.
al****@spenarnc.xs4all.nl http://home.hccnet.nl/a.w.m.van.der.horst

Nov 15 '05 #108
"Paul Marciano" <pm***@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...

(if you're still reading this... wow... you need to find a hobby).


I liked you until I got to the end.

--
Mabden
Nov 15 '05 #109
"John Hudak" <jh****@sei.cmu.edu> wrote in message
news:dh**********@usenet02.sei.cmu.edu...
Personally, sometimes I like top.......
I get it! You are talking about how your boyfriend sometimes letting you
bang him! Very witty! ;-0
Lanarcam wrote:
Paul Marciano wrote:
Robert Scott wrote:

It amazes me how some people can claim to speak for the whole group
with no documentation at all. I, for one, appreciate top-posting whenit is appropriate.
I like gotos when appropriate. A very rare occurance.
But now it appears it's something so small - the order of text within amessage. My God... how anal some people are. Ok, that's unfair, butonly just.
Indeed, so small. Such a stupid thing for one person to object to, when
dozens point it out, and hundreds stop reading, and thousands roll their
eyes, and millions... well, you'll never be read by millions.
You know, people are clever. They can figure out messages. I don't
see how your personal quests do anything but make you feel important.

Talk to someone in the public eye: politics, radio, tv. For every person
who actually takes the time to correct you, there are many who don't
bother. Remember that time you had that thing on your face and seven
people avoided you until someone told you to check yourself. Magnify to
10,000.

If that doesn't convince you, think of the last time someone said,
"Dude, you are too drunk to ..." and consider whether or not they were
right.
I don't know. This thread amazes me. It simply amazes me.

Yet the rest of us see this pig-headedness ALL THE TIME. Underwhelming.
Gulliver would perhaps have called that the battle of
top postians vs bottom postians ;)

As I recall no one changed their minds, but Gulliver had to leave.
and sometimes I like bottom....(also in posting too... (are smilies
allowed? :) ....))
Wow, with all the other issues there are in this forum to discuss, I
can't believe how anal some ppl are....sheesh!


Hey, you should see what I go through for dropping a joke, or
recommending poetic formula in answers...
I can get away with 2-3 jokes a quarter, but man, even if I save up for
a year I get grief when I unload.

Oh, and don't even THINK about saying, "U R" or "ppl", or "l33t".

--
Mabden
Nov 15 '05 #110

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
4032
by: Kamilche | last post by:
I was looking for a way to speed up detecting invalid characters in my TCP string, and thought of yet another use for the translate function! If you were to 'translate out' the bad characters, and...
1
1866
by: Rudy Koento | last post by:
Hi, I've created an index but it's not being used by postgresql when doing a query. But doing an "explain analyze" shows that with index, it's faster. Here's the output: ...
34
3385
by: sushant | last post by:
hi all, suppose i have 2 loops one inside the other, like this 1) for(i=0;i<=100;i++) { for(j=0;j<=10;j++) { some code; }
11
1238
by: bill | last post by:
I am trying to figure out if I can use sse to help execute arithmetic operations faster. I have 900 values that must each be scaled with a divide and multiply. This happens repeatedly. Any examples...
2
1550
by: Jeffrey Melloy | last post by:
I have been using tsearch2 for quite a while with a fair amount of success. The other day I was playiing around with a query, and randomly changed a few things. I noticed a 10 times speedup and...
11
1519
by: Farel | last post by:
Which is Faster in Python and Why? jc = {}; m = x = ,,.......] # upwards of 10000 entries def mcountb(): for item in x: b = item; b.sort(); bc = 0 for bitem in b: bc += int(bitem) try: m...
5
3528
by: sololoquist | last post by:
#define COUNT_UP #include <stdio.h> #define N 10 int main() { int i; #ifdef COUNT_UP for (i = 0; i < N; i++)
23
13288
by: AndersWang | last post by:
Hi, dose anybody here explain to me why memset would be faster than a simple loop. I doubt about it! In an int array scenario: int array; for(int i=0;i<10;i++) //ten loops
17
1951
by: onkar | last post by:
which one runs faster ?? for(i=0;i<100;i++) for(j=0;j<10;j++) a=0; OR for(j=0;j<10;j++) for(i=0;i<100;i++)
0
7344
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7069
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
5652
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5060
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
3216
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
3203
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1570
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
775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
441
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.