[Gambas-user] For...Next loop efficiency question

Rolf-Werner Eilert eilert-sprachen at ...221...
Thu Feb 23 09:20:17 CET 2012


Kevin,

As far as I found out, it is done only once at the beginning. Just make 
a test: set a stop point before the loop, and than make single steps 
through the loop watching the local variables.

I use this for getting clear about efficiency from time to time, and I 
found it a pretty eye-opener on how my programs actually are running.

Rolf

Am 23.02.2012 06:16, schrieb Kevin Fishburne:
> If the ranges of a For...Next loop require calculations, are they slower
> than a loop which doesn't? In other words, is the first example below
> faster than the second?
>
> For Counter = 1 To 100
> Next
>
> For Counter = 100 / 100 + 1 - 1 To 100 / 100 + 1 - 1 + 99
> Next
>
> Does it make any difference if the calculations use variables versus
> explicit numbers like in my example?
>
> Modifier = 100
> For Counter = 1 + Modifier To 100 + Modifier
> Next
>
> I guess what I'm getting at is, is the calculation performed once at the
> beginning of the loop, or is the calculation performed repeatedly, after
> every Next?
>





More information about the User mailing list