Re: break statement in a for loop
- From: a.mil@xxxxxxxxx
- Date: 29 Apr 2007 00:34:54 -0700
It's not my objective to show you the full code; it's about the issue
of execution speed and "break".
Richard Heathfield schreef:
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: christian.bau
- Re: break statement in a for loop
- From: Malcolm McLean
- Re: break statement in a for loop - TPA
- From: Default User
- Re: break statement in a for loop
- From: Richard Heathfield
- 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
- Re: break statement in a for loop
- From: Richard Heathfield
- break statement in a for loop
- Prev by Date: Re: long integer multiplication
- 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
|