Re: break statement in a for loop
- From: Richard Heathfield <rjh@xxxxxxxxxxxxxxx>
- Date: Sun, 29 Apr 2007 07:32:58 +0000
a.mil@xxxxxxxxx said:
Ok, this was a bad fast example, I admit.
Therefore below another example that shows the point.
int main()
{
unsigned long i,j,k,l,n;
for (l=0;l<10000000;l++) {
j=0;
k=10;
n=231;
for (i=1;n>3;j+=8,k+=j,n-=2) {
if (k%n) continue;
i=0;
break;
}
}
return 0;
}
Run this without the break statement and with the break statement and
look at execution time. On my 1.5GHz P4 it takes 1.3s and 13.9s
respectively (!). My store on the factor 100 incorporates a lot more
code.
The same result can be achieved much more quickly:
int main(void)
{
return 0;
}
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
.
- Follow-Ups:
- Re: break statement in a for loop
- From: a . mil
- Re: break statement in a for loop
- References:
- break statement in a for loop
- From: a . mil
- Re: break statement in a for loop
- From: a . mil
- break statement in a for loop
- Prev by Date: Re: Utility to convert complex declarations into, well, lol, plain-text
- Next by Date: Re: long integer multiplication
- Previous by thread: Re: break statement in a for loop
- Next by thread: Re: break statement in a for loop
- Index(es):
Relevant Pages
|