www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/04/16:41:26

From: john AT devereux DOT demon DOT co DOT uk (John Devereux)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Theoretical question of loops
Date: Tue, 04 Feb 1997 19:33:16 GMT
Message-ID: <32f752d7.96753319@news.demon.co.uk>
References: <32F443AF DOT 51CF AT dmv DOT com>
NNTP-Posting-Host: devereux.demon.co.uk
MIME-Version: 1.0
Lines: 35
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Sun, 2 Feb 1997 07:35:11 GMT, Pyro Technic <invid AT dmv DOT com> wrote:

>I've got a weird question, wich would be faster and how would I
>measuree it. Would doing 2 things 3 times be faster or slower than doing
>3 things 2 times.
>
>
>// loop set 1
>//is this faster
>for(i=0; i<3; ++i)
>	{
>	for(j=0; j<2; ++j)
>		{
>		//stuff here
>		}
>	}
>
>// loop set 2
>//or is this 
>for(i=0; i<2; ++i)
>	{
>	for(j=0; j<3; ++j)
>		{
>		//stuff here
>		}
>	}
>
>weird stuff. Thanks a lot.
>
>	Pyro


The second version is faster, I think. There is less overhead because
the code to initialise the inner loop is executed less often.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019