The reason I ask specifically of the repeated references is, during one
of the sessions at U2UG-Denver, it was implied that each time you
reference a specific location in a table, the OS basically has to start
at the beginning of the table and 'find' its way to that location
(explained in my over-simplified way of thinking).

Thus why the REMOVE statement is preferred when sequentially referencing
a table rather than a FOR/NEXT loop referencing each element
individually.  The REMOVE statement keeps a pointer as to where it left
off in the table and simply goes to the next AM/VM/SM/RM

I have personally experienced (and thus embraced) the truly
extraordinary performance improvement with the REMOVE statement and
would encourage everyone to do so as well.

To address a couple comments:

This would appear to me to be 'textbook' code, implying it was likely
written by a newly graduated college student. With all due respect to
college grads, I can't believe some of the code I wrote a few years ago,
let alone what I must have done fresh out of college.

This code is likely 15+ years old and certainly could use a facelift, as
could any of us after any 15-year stint of our lives. To get more
detailed would be debating cosmetics ... a debate not intended for this
thread.

Nearly half-a-million records run through this code each month, it takes
about 1.5 hours and is critical that it run at peak efficiency.
Therefore my primary objective is performance.

Thank you all for the rousing debate.

That being said, I think I'll do my modifications and let the group know
what the results are.

Once again, thank you!

Sincerely,
David Laansma
IT Manager
Hubbard Supply Co.
Direct: 810-342-7143
Office: 810-234-8681
Fax: 810-234-6142
www.hubbardsupply.com
"Delivering Products, Services and Innovative Solutions"

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Steve Romanow
Sent: Wednesday, March 02, 2011 11:50 AM
To: U2 Users List
Subject: Re: [U2] Is this worth rewriting?

On 3/2/2011 11:43 AM, Dave Laansma wrote:
> This is some old code that I didn't write, so please don't use it for
> anything profitable ...
>
>
>
> The proposal to the group is: Due to the repeated references deep into
> the PARMS tables, if this were rewritten to reference these locations
as
> few times as possible, IN YOUR OPINION, would there be a significant
> improvement in the performance of this subroutine?
>
>
>
> All in favor of rewrite, say AYE
>
> All opposed, say NAY
>
>
>
> (I'm testing some U2UG-Denver skills)
>
>
>
> MONTHLY.USAGE:
>
>
>
>         CM=MONTH+LY.CNT
>
>         FOR M=1 TO 12
>
>           IF PARMS(12)<101,CM>#'' OR PARMS(12)<133,CM>#'' OR
> PARMS(12)<134,CM>#'' THEN
>
>
>
>
CUM(M)=PARMS(12)<101,CM>+PARMS(12)<133,CM>+PARMS(12)<134,CM>
>
>           END
>
>           IF PARMS(7)<100,CM>#'' OR PARMS(7)<101,CM>#'' OR
> PARMS(7)<102,CM>#'' THEN
>
>
>
>             IF PARMS(7)<100,CM>#'' THEN
CUMO(M)=CUMO(M)+PARMS(7)<100,CM>
> ELSE
>
>               CUMO(M)=CUMO(M)+PARMS(12)<101,CM>
>
>             END
>
>             IF PARMS(7)<101,CM>#'' THEN
CUMO(M)=CUMO(M)+PARMS(7)<101,CM>
> ELSE
>
>               CUMO(M)=CUMO(M)+PARMS(12)<133,CM>
>
>             END
>
>             IF PARMS(7)<102,CM>#'' THEN
CUMO(M)=CUMO(M)+PARMS(7)<102,CM>
> ELSE
>
>               CUMO(M)=CUMO(M)+PARMS(12)<134,CM>
>
>             END
>
>           END
>
>           CM=CM-1; IF CM=0 THEN CM=24
>
>         NEXT M
>
>         RETURN
>
>
>
> _______________________________________________
> U2-Users mailing list
> [email protected]
> http://listserver.u2ug.org/mailman/listinfo/u2-users
I dunno.  If it works and the performance is GoodEnough, I would leave 
it.  Parms is already a dimmed array, so each element is addressed 
independently.

Might be fun to use the U2 vector functions on it and get rid of the 
loop, i.e. OCONVS() and SUM() instead of the loop.
_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users
_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to