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

Emil Lenngren emil.lenngren at ...626...
Thu Feb 23 09:33:47 CET 2012


Gambas is open source, so you can always look in the source code how
everything is implemented. e.g. look in gbx_exec_loop.c and look for
jump_next.

/Emil

2012/2/23 Rolf-Werner Eilert <eilert-sprachen at ...221...>

> 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?
> >
>
>
>
> ------------------------------------------------------------------------------
> Virtualization & Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



More information about the User mailing list