Mail Archives: djgpp/1997/02/04/16:41:26
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 -