Yes,
I do agree that when looked at in terms of cpu time it is most likely
negligible in 99.9% of cases.
I think I heard about the integer vs zoned/packed in loops somewhere here
on midrange, or maybe some article somewhere. But I use integer variables
exclusively in loop constructs now and it does make a nice difference.
Thanks
Bryce Martin
Programmer/Analyst I
570-546-4777
John Yeung <gallium.arsenide@xxxxxxxxx>
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
06/22/2011 11:09 PM
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...
On Fri, Jun 17, 2011 at 11:23 AM, Bryce Martin <BMartin@xxxxxxxxxxxx>
wrote:
This is why I was kind of taken back by this. I had thought that there
wouldn't be a difference... or maybe ever so slight.
Your surprise is understandable. As far as I can tell, the FOR loop
is just syntax sugar for a DOW with initialization, increment, and
limit test. Nothing more. It would not be hard to write a program
which scans RPG source code, finds FOR loops, and converts them to
DOW. Therefore, it should not be hard to make the RPG compiler do the
same. It shouldn't even require optimization; it really should just
be *equivalent* to DOW. Maybe some IBM insiders or experts can
enlighten us with details why this is not so. (And yes, I read the
Code400.com thread. I didn't find the responses by DAG0000 and
MichaelCatalani very informative. At least the latter acknowledged
that a sufficiently smart compiler *could* generate equally efficient
code for either type of loop.)
That said, even if it is true that FOR can always be trivially
converted to DOW, I have to agree with the folks who say the
suboptimal performance of FOR is not a big deal. A much bigger deal,
as you and others showed on Code400.com, is that packed data is much
slower than integer! And I am pretty sure that almost all legacy
code, as well as almost all new code written by "legacy programmers"
(including me, I'll admit) only uses packed and zoned numeric types,
just because that's what was always available and convenient.
John
As an Amazon Associate we earn from qualifying purchases.