Re: which one runs faster ??



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/
.



Relevant Pages

  • Re: Programming Contest
    ... in CLC. ... I know in advance what the response is going to be like. ... IF I ever have to get another compiler ... My approach, discounting coding style, makes sense. ...
    (comp.lang.cobol)
  • Re: checking if NUMERIC
    ... The compiler controls what gets moved to fields. ... 'Obviously' is in the mind of the beholder, Mr Dashwood... ... The calendar may have said forty years... ... practice, and try to think about things from different perspectives. ...
    (comp.lang.cobol)
  • Re: checking if NUMERIC
    ... The compiler controls what gets moved to fields. ... 'Obviously' is in the mind of the beholder, Mr Dashwood... ... The calendar may have said forty years... ... practice, and try to think about things from different perspectives. ...
    (comp.lang.cobol)
  • Re: Maximum String size in Java?
    ... > newsgroup where gcc experts are known to reside. ... redirections in clc, it's an observation that's been made by up upset ... of platform or compiler specificity. ...
    (comp.programming)
  • Re: Is it standard and practical to use long long types?
    ... >lcc-win32 implements most of C99. ... through the hassle to maintain a C compiler for non-profit. ... And rightfully so, for the reasons given above, and in an impressive ... better places to put it than the body of a message posted to clc. ...
    (comp.lang.c)

Loading