Just had the two loops laying around that I was messing with and decided
to time them. I also have done a test on (for x=1 to bigNum) and it was
actually slower than the for/downto test. Not a ton slower, but some.
Incrementing/Decrementing... either way... the relative performance
difference is still there.
Thanks
Bryce Martin
Programmer/Analyst I
570-546-4777
"Morgan, Paul" <Paul.Morgan@xxxxxxxxxxx>
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
06/17/2011 09:47 AM
Please respond to
RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>
To
RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>
cc
Subject
RE: Performance test: DOW vs FOR.... interesting results...
Martin,
Why are you decrementing the For loop but incrementing the Do While?
Paul Morgan
Principal Programmer Analyst
IT Supply Chain/Replenishment
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Bryce Martin
Sent: Friday, June 17, 2011 9:37 AM
To: RPG programming on the IBM i / System i
Subject: Performance test: DOW vs FOR.... interesting results...
Ok, so out of curiosity yesterday I was doing some DOW vs FOR comparisons
and thought that while I was at it I would do a performance test...and
this uncovered something interesting...
Here's the long of the short of it...
DOW is 3x faster than FOR. If you use OPTIMIZE(*FULL) then the gap is
even greater.
Now, before anyone says it... yes...we're talking about milliseconds here.
But think of all your programs that have loops...yep, almost all of them.
So I guess my main question is this...
Why the big relative difference? How is it that FOR can be so much worse
than DOW? You can actually see a difference if doing 10's or 100's of
millions of iterations. So while most people won't see a difference in
individual instances, if all your FOR loops were 3 times faster in all
your programs, I can't help but think you might be able to see some actual
performance across a fairly taxed system.
I don't know... just ruminating. Anybody have any gritty details?
See this link for code and discussion....
http://www.code400.com/forum/showthread.php/10499-DOW-x-lt-y-is-3-times-faster-than-using-for-x-number-downto-1
Thanks
Bryce Martin
Programmer/Analyst I
570-546-4777
--- This message (including any attachments) is intended only for the use
of the individual or entity to which it is addressed and may contain
information that is non-public, proprietary, privileged, confidential, and
exempt from disclosure under applicable law. If you are not the intended
recipient, you are hereby notified that any use, dissemination,
distribution, or copying of this communication is strictly prohibited. If
you have received this communication in error, please notify us and
destroy this message immediately. ---
As an Amazon Associate we earn from qualifying purchases.