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.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.