Re: [fpc-pascal] for loop vs while loop

2017-02-02 Thread Lars
On Wed, February 1, 2017 4:49 am, Graeme Geldenhuys wrote: > Hi, > > > Just curious (been in a discussion with somebody else). Is there a > performance difference between a FOR loop and a WHILE loop? > > Not sure if it will make a difference, but the usage is with three > nested loops, iterating

Re: [fpc-pascal] for loop vs while loop

2017-02-02 Thread DaWorm
On Thu, Feb 2, 2017 at 4:01 AM, Mark Morgan Lloyd < markmll.fpc-pas...@telemetry.co.uk> wrote: > > It's interesting that the real (wallclock) and user times are consistently > in a different sequence. /If/ the user time is to be believed, there's a > very small advantage to counting down even if

Re: [fpc-pascal] for loop vs while loop

2017-02-02 Thread Mark Morgan Lloyd
On 01/02/17 20:30, Nitorami wrote: Just a note - I learned that for very short "for" loops it may be even a bit faster to count downwards (to zero) rather than upwards if possible, because the comparison to zero is very effiicient. Not sure though whether that still makes a difference on modern

Re: [fpc-pascal] for loop vs while loop

2017-02-01 Thread Nitorami
Just a note - I learned that for very short "for" loops it may be even a bit faster to count downwards (to zero) rather than upwards if possible, because the comparison to zero is very effiicient. Not sure though whether that still makes a difference on modern processors. -- View this message

Re: [fpc-pascal] for loop vs while loop

2017-02-01 Thread Jürgen Hestermann
Am 2017-02-01 um 12:49 schrieb Graeme Geldenhuys: > Just curious (been in a discussion with somebody else). Is there a > performance difference between a FOR loop and a WHILE loop? > Not sure if it will make a difference, but the usage is with three > nested loops, iterating over some 300,000

Re: [fpc-pascal] for loop vs while loop

2017-02-01 Thread Graeme Geldenhuys
On 2017-02-01 12:12, Mattias Gaertner wrote: > Yes, for-loop calculates the end value only once. Ah, thanks for that. Seems so obvious now. :) Regards, Graeme ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org

Re: [fpc-pascal] for loop vs while loop

2017-02-01 Thread Mattias Gaertner
On Wed, 1 Feb 2017 11:49:34 + Graeme Geldenhuys wrote: > Hi, > > Just curious (been in a discussion with somebody else). Is there a > performance difference between a FOR loop and a WHILE loop? Yes, for-loop calculates the end value only once. > Not sure