Re: which one runs faster ??
- From: Spiro Trikaliotis <news-200605@xxxxxxxxxxxxxxx>
- Date: Fri, 1 Jun 2007 20:32:44 +0200
Tak <kakataka@xxxxxxxxx> schrieb:
On 5??30??, ????7??23??, onkar <onkar....@xxxxxxxxx> wrote:
which one runs faster ??
for(i=0;i<100;i++)
for(j=0;j<10;j++)
a[i][j]=0;
OR
for(j=0;j<10;j++)
for(i=0;i<100;i++)
a[i][j]=0;
I thought them run in the same time, haha , I am new at c/c++;
leaving the topic of clc (that is: speaking OT), in practice, both can
differ significantly, but they do not need to. If the compiler
translates these "literally", you might even end up thrashing your
virtual memory (making this statement even more OT), resulting in
factors of 1000 or more between both statements.
Of course, for this to happen, it is likely that the values 100 and 10
must be much bigger than in the "samples" above.
Ok, now I'll shut my OT mouth. ;)
Regards,
Spiro.
--
Spiro R. Trikaliotis http://opencbm.sf.net/
http://www.trikaliotis.net/ http://www.viceteam.org/
.
- Prev by Date: Re: How to print "\n" or '\0'
- Next by Date: Re: how to add two no. of 100 digits or more?
- Previous by thread: Puzzle!
- Next by thread: i am new to usenet, need help on how to use it.
- Index(es):
Relevant Pages
|
Loading