Saying that MATREAD/MATWRITE improves performance without any other
context is misleading.  Yes, MATREAD/MATWRITE _can_ improve
performance but it isn't a cure all for performance problems.  In
programs where there is a lot of dynamic array manipulation
(extraction, replacement, insertion, deletion) of later attributes
(let's say > 50 as a very rough example) using dimensioned arrays can
improve the performance of repeated references to those attributes.
Then again, would you consider something like the following to be good
code?

FOR LINE.LOOP = 1 TO LINE.CNT
  IF RECORD<50,LINE.LOOP> = 'C' THEN
     (or alternatively)
  IF RECORD(50)<1,LOOP.LOOP> = 'C' THEN
  ...requisite END and NEXT to follow

Given this situation specifically, the dimensioned array will perform
better than the dynamic due to the repetitive extraction from the 50th
attribute.  But that doesn't mean the dimensioned array is the best
solution!  Instead, the code could be written more effectively to use
the flexibility (and syntactic simplicity) of dynamic arrays and still
perform as well.

LINE.STATUS.CDS = RECORD<50>
FOR LINE.LOOP = 1 TO LINE.CNT
  IF LINE.STATUS.CDS<1,LINE.LOOP> = 'C' THEN
   ....requisite END and NEXT to follow

In fact, it might even perform better.  See, the dimensioned arrays
work faster because you're never working with more than a single
attribute at a time in any dimension position (with the exception of
the situation where you're MATREADing into an array that's
undersized).  That makes access to any specific attribute very, very
fast.  Extracting an attribute from a dynamic array into a local
variable mimics what happens with the MATREAD, but without the
overhead of parsing all attributes into individual variables (as there
would be with MATREAD) so all other things being equal, this might
actually produce faster code with dynamic arrays than with
dimensioned.  The equalizer will be the number of extractions and
replacements w/ the dynamic array.

-Kevin
[EMAIL PROTECTED]
http://www.PrecisOnline.com

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Stevenson,
Charles
Sent: Friday, May 13, 2005 1:50 PM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] I'm in an Array quandry, any suggestions...

Maybe the Smart People on this list can give a good rule of thumb for
deciding when to READU/WRITE vs. MATREADU/MATWRITE.   After all these
years, I still don't have one.

From: Richard Taylor
>
> We are faced with this same situation and the thought behind this 
> truly baffles me.

I will admit to some of the same bafflement.

> Why take a flexible, dynamic database system

The syntax for dynamic arrays is more natural for the language, too
(e.g., XYZ(17)<1,5>  vs. XYZ<17,5>).
Readability makes for maintainability, generally the most important
contributor to software quality.

> and force it to be fixed length.

well, sorta.  Each element of the dimensioned array is a variable
length dynamic array.  ( See my previous post for how to complicate
your life by inserting attribute marks. )

> This is what you are doing using dimensioned arrays and MATREADs.
The
most 
> common justification I have heard is performance and this simply
does
not hold
> water.

Within limits (but I don't know the limits).
If you have a program that manipulates many attributes many times,
then it makes sense to matread them into a dimensioned array up front,
and matwrite them in the end, thereby limiting big string
manipulations.
People forget or newbies don't know that CUST.REC<117> is really
EXTRACT( CUST.REC, 117,0,0) or REPLACE(...,CUST.REC,117,0,0).  That
can be very expensive when you do that for many attributes many times,
with
large dynamic arrays.   By contrast, each dimensioned array element
has
its own memory address, so references and assignments can jump
straight to it.

But I do not have a good appreciation for what "limits", "many", "big"
really mean in my previous paragraph.  Does anyone have a good
heuristic?

>  I started in Pick in R83 and have never used a dimensioned array to

> hold record structure and I have not seen performance issues.  This
to
the
> extent that we ran an MRP run on a 286 Wyse PC that choked the
mainframe at
> this company.

Ah-ha, my dear Watson, then you don't really know how that system
would have screamed if you'd used dimensioned arrays instead, do you?

>
> "The more they complicate the plumbing
>   the easier it is to stop up the drain"

Yeah.  What I said about dynamic array syntax being more natural.

cds

P.S.  Why are we limited to 1- or 2-dimensioned arrays?
      E.g.,  DIM XYZ( 5,10,2,3,8 ) would be a 5-dimensional array.
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.11.9 - Release Date: 5/12/2005
 

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.11.9 - Release Date: 5/12/2005
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to