From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Theoretical question of loops Date: Sun, 02 Feb 1997 04:05:22 -0800 Organization: Two pounds of chaos and a pinch of salt Lines: 23 Message-ID: <32F48302.2186@cs.com> References: <32F443AF DOT 51CF AT dmv DOT com> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp107.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Pyro Technic 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. If the code inside the loops is identical (i.e., you don't need to do something wierd to the code if 'i' and 'j' need to be reversed, then they should run at exactly the same speed. What matters isn't the number of loops, but what's inside them. Alternatively, if you're compiling with maximum optimizations and the compiler decides that one or more of those loops can be "unrolled", then you might see a difference, but that's really esoteric and not realistic to consider for most programs. :) -- --------------------------------------------------------------------- | John M. Aldrich, aka Fighteer I | mailto:fighteer AT cs DOT com | | God's final message to His Creation: | http://www.cs.com/fighteer | | "We apologize for the inconvenience."| Fight against proprietary | | - Douglas Adams | software - support the FSF!| ---------------------------------------------------------------------