The runtime does not maintain a pointer to each cell in a dimensioned array.
The cell positions are *calculated* using an initial offset address and then a 
formula.  No pointers.
Or *one* if you prefer to call the offset address a pointer to the start of the 
array.

The moving pointer into a dynamic array however is a true full-address pointer.

A dimensioned array has 1000 cells, fixed in position, and no pointers.
A dynamic array has a string pre-set at a certain size (which can grow by 
dynamic linking) and a single pointer to your current position.

The issue with picking up and laying down the string is not related to the 
dynamic linking.  If you address yourself into the middle of the string, the 
system has no choice but to pick up and rewrite the entire string, in order to 
shift the end.  The reason why it's probably faster to address the end, is that 
possibly this has been optimized to simply write at the end, and not bother 
with the rest of it.  Not sure, I may be wrong on that point.

The reason why the VM version is slow, is simply because the system was never 
optimized to carry a pointer when using a VM array. That's all.
So it has to rescan the whole string every time you change it, including 
appending.

By the way, why are you bringin in dimensioned in the first place?  I don't 
anyone was talking about that.


-----Original Message-----
From: David L. Wasylenko <d...@pickpro.com>
To: U2 Users List <u2-users@listserver.u2ug.org>
Sent: Thu, Jul 12, 2012 4:26 pm
Subject: Re: [U2] trimming a list (a test of your ability)


Not exactly.
urrent position of EACH unique variable...
nd a DIM BIG(1000) has/is 1,000 unique variables.
So 1,000 unique pointers.
nd the "writing whole string" --- yes it would, if the size outstrips the 
emory allocated.
y using 1,000 smaller strings, the move is triggered much less often, allowing 
he append operation VS reallocation of a new, larger memory buffer.
With REC<-1> or REC<1,-1> syntax:
Using a *single* variable, 1,000,000 iterations:
am delimited = 21.719 seconds, ranging from 41,545 iterations a second to 
5,161, very consistant
vm delimited = ( Had to stop it at 100,000 iterations, 235.561 seconds) 
        from 12,787 iterations a second at start down to 449 per sec at 100,000 
alues, consistently slower and slower
  Just using REC<-1> saved a HUGE amount of time.
Using a DIM(1000) variable:
vm delimited = 24.859 seconds  39,553 to 317,460 per second;  wide swing but 
uch faster than a single variable
am delimited = 3.781 seconds    245,158 to 425,531  per second; the big winner

he @VM delimiter will continually get slower and slower using either method, 
owever, the slowdown occurs only 1,000 times.
o in either case, the savings is significant using @AM -  the DIM() concept is 
cing and the best method I've seen.

... david ...
David L. Wasylenko
resident, Pick Professionals, Inc
) 314 558 1482
l...@pickpro.com

----Original Message-----
rom: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org] 
n Behalf Of Wjhonson
ent: Thursday, July 12, 2012 4:16 PM
o: u2-users@listserver.u2ug.org
ubject: Re: [U2] trimming a list (a test of your ability)

 beg to differ.
he runtime maintains a pointer to *your current attribute*, as I understand it.
Not to *each* attribute location.
ne buffer location, not a thousand.
If it maintained a pointer to *each* attribute location, you could jump around 
n the variable at random and has access as quick as a dimensioned array gives 
ou.  But I believe that is not the case.
By-attribute insertion is quick *only* because you are always inserting at the 
urrent position (or the next).
hange this to a locate with insertion and it should dramatically slow down.
his is because the entire string is being picked up and put down on each 
nsert.  The whole string.
 think in the case of insertion at the end (the current position) it doesn't 
ctually pick up and rewrite the whole string on each append.
ust the end of the string.




----Original Message-----
rom: David L. Wasylenko <d...@pickpro.com>
o: U2 Users List <u2-users@listserver.u2ug.org>
ent: Thu, Jul 12, 2012 2:09 pm
ubject: Re: [U2] trimming a list (a test of your ability)

ope;
s to do with how systems handle system delimiters.
namic arrays maintain pointers to attribute locations, but not the @VM ointers.
e system already has buffering, memory management etc. for string anipulation.
owever, what makes it fast is the routine makes use of 1,000 different memory 
cations, ach being vastly smaller than the final resulting record.
ach element of the array is smaller string, resulting in less paging, heap 
nipulation etc.
he following example uses ONE variable instead of the previous 1000; xecution 
ime is 21.735 seconds compared to the prior version: 3.75 seconds
1:    D.ARRAY="" ; START.TIME=TIME()
:    FOR PTR=1 TO 1000000
:       GOSUB H.ADD                        ; * add to array
: !      IF NOT(MOD(PTR,1000)) THEN CRT PTR
:    NEXT PTR
:    GOSUB H.RESULT
:    END.TIME=TIME()
:    CRT END.TIME, START.TIME, END.TIME-START.TIME
:    STOP
: **********
: H.ADD:* add to array
: **********
:    D.ARRAY<-1>=PTR
: *
:    RETURN
: **********
: H.RESULT:* construct resulting array
: **********
:    D.ARRAY=CHANGE(D.ARRAY,@AM,@VM)
: *
:    RETURN
: *
: * end of job
: *
: END
david .
avid L. Wasylenko
esident, Pick Professionals, Inc
 314 558 1482
w...@pickpro.com
----Original Message-----
om: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org]
 Behalf Of Daniel McGrath
nt: Thursday, July 12, 2012 3:20 PM
: U2 Users List
bject: Re: [U2] trimming a list (a test of your ability) You are probably 
hinking about the technique  of pre-allocating the chunk of emory first, then 
anually overwriting sections instead of appending to the nd. This saves on 
ystem calls to allocate new memory. I think there used to be omething on pick 
iki about it.
egards,
n
----Original Message-----
om: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org]
 Behalf Of David L. Wasylenko
nt: Thursday, July 12, 2012 12:58 PM
: U2 Users List
bject: Re: [U2] trimming a list (a test of your ability) I recall using 
ttributes can be faster...  This ran in 4.297 seconds with the isplay AND 3.75 
ithout the progress display.
t it took 24.656 seconds using @VM as delimiter.
1:    DIM BIG(1000) ; MAT BIG=""
:    D.ARRAY="" ; START.TIME=TIME()
:    FOR PTR=1 TO 1000000        ;* one million
:       GOSUB H.ADD                        ; * add to array
:       IF NOT(MOD(PTR,1000)) THEN CRT PTR  ;* progress display
:    NEXT PTR
:    GOSUB H.RESULT
:    END.TIME=TIME()
:    CRT END.TIME, START.TIME, END.TIME-START.TIME
:    STOP
: **********
: H.ADD:* add to array
: **********
:    SEG.PTR=MOD(PTR,1000)+1
:    BIG(SEG.PTR)<-1>=PTR       ;* alternate BIG(SEG.PTR)<1,-1>=PTR
: *
:    RETURN
: **********
: H.RESULT:* construct resulting array
: **********
:    MATBUILD RESULT FROM BIG USING @AM
:    MV.RESULT=CHANGE(RESULT,@AM,@VM)
: *
:    RETURN
: *
: * end of job
: *
: END
david .
avid L. Wasylenko
esident, Pick Professionals, Inc
 314 558 1482
w...@pickpro.com
----Original Message-----
om: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org]
 Behalf Of Daniel McGrath
nt: Thursday, July 12, 2012 1:50 PM
: U2 Users List
bject: Re: [U2] trimming a list (a test of your ability)
es, exactly. If you starting breaking down what would be happening behind the 
enes, you can see why X<-1>=I will be faster than X:= @AM:I will be faster han 
= X:@AM:I Hint, it is all about memory management, temporary variables, 
ndividual byte ode ops and big O complexity (not necessarily in that order).
----Original Message-----
om: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org]
 Behalf Of David A. Green
nt: Thursday, July 12, 2012 10:25 AM
: 'U2 Users List'
bject: Re: [U2] trimming a list (a test of your ability) Ah, but try it with := 
nstead of Y = Y:
avid A. Green
80) 813-1725
G Consulting
----Original Message-----
om: u2-users-boun...@listserver.u2ug.org
ailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Daniel McGrath
nt: Thursday, July 12, 2012 8:56 AM
: U2 Users List
bject: Re: [U2] trimming a list (a test of your ability) ROUNDS = 10000 OOP
 X = '' ; Y = ''
 START.TIME = TIME()
 FOR I = 1 TO ROUNDS
    X<-1> = I
 NEXT I
 END.TIME = TIME()
 CRT END.TIME-START.TIME : " vs " :
 START.TIME = TIME()
 FOR I = 1 TO ROUNDS
    Y = Y:CHAR(254):I
 NEXT I
 END.TIME = TIME()
 CRT END.TIME-START.TIME
 ROUNDS *= 2
PEAT
---
esults suggest that you should od <-1>, not the multiple concatenation.
an McGrath
oduct Manager
cket Software
00 S. Ulster Street ..Suite 1100 ..Denver, CO 80237 . USA
 +1.720.475.8098 . m: +1.617.630.7392 . e:dmcgr...@rocketsoftware.com w:
cketsoftware.com/u2

----Original Message-----
om: u2-users-boun...@listserver.u2ug.org
ailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of George Gallen
nt: Thursday, July 12, 2012 7:30 AM
: U2 Users List
bject: Re: [U2] trimming a list (a test of your ability) Instead of <-1>, use  
tring=string:char(254):additionalelement
eorge
----Original Message-----
om: u2-users-boun...@listserver.u2ug.org
ailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Dave Laansma
nt: Thursday, July 12, 2012 9:20 AM
: Marco Manyevere; U2 Users List
bject: Re: [U2] trimming a list (a test of your ability) This is the best 
olution, using REMOVE and building a new list instead of onstantly 'shrinking' 
he original table.
hat being said, as NEW.LIST gets rather large, adding new elements to it can et 
time' consuming. Just like the REMOVE keeps track of the pointer as you pin 
hrough a table, I wish there was a comparable statement that kept track of he 
ointer as we added new elements <-1> to tables.
incerely,
vid Laansma
 Manager
bbard Supply Co.
rect: 810-342-7143
fice: 810-234-8681
x: 810-234-6142
w.hubbardsupply.com
elivering Products, Services and Innovative Solutions"
----Original Message-----
om: u2-users-boun...@listserver.u2ug.org
ailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Marco Manyevere
nt: Thursday, July 12, 2012 4:14 AM
: U2 Users List
bject: Re: [U2] trimming a list (a test of your ability) Is this what the OP is 
sking about or I'm missing something? The 2 code ragments look totally 
ifferent. We dont know what's happening in ET.UTILITY.RECORD or the 
ignificance of UTILITY.NAME and LAST.NAME to totally liminate them during the 
optimisation'
 would rather do:
EW.LIST = ''
OP
REMOVE UTILITY.ID FROM KEY.LIST SETTING MORE WHILE MORE:UTILITY.ID  GOSUB 
ET.UTILITY.RECORD
 IF INDEX(UTILITY.NAME,LAST.NAME,1) = 0 THEN CONTINUE
 NEW.LIST<-1> = UTILITY.ID
PEAT
Y.LIST = NEW.LIST
W.LIST = '' ;* free the memory
________________________________
rom: Kate Stanton <k...@walstan.com>
: U2 Users List <u2-users@listserver.u2ug.org>
nt: Thursday, 12 July 2012, 4:27
bject: Re: [U2] trimming a list (a test of your ability)

am getting sucked in!
LST = ""                                                       ;* For new list 
XI = DCOUNT(KEY.LIST<1>,@vM)         ;* Count items FOR INO =1 TO MAXI        
                         ;* Each key in list
KEY.ID = KEY.LIST<1,INO>                        ;* A key ID
LOCATE(KEY.ID,NLST,1;POS;'AL') ELSE  ;* see if there
  INS KEY.ID BEFORE NLIST<1,POS>       ;* Sort to list
END
XT INO                                                      ;* Check all keys 
 12 July 2012 12:09, Wjhonson <wjhon...@aol.com> wrote:

1295          FOR DISPLAY.LOOP = 1 TO KEY.COUNT
1296             UTILITY.ID = KEY.LIST<1,DISPLAY.LOOP>
1297             GOSUB GET.UTILITY.RECORD
1298             IF INDEX(UTILITY.NAME,LAST.NAME,1) = 0 THEN
1299                KEY.LIST = DELETE(KEY.LIST,1,DISPLAY.LOOP,0)
1300                DISPLAY.LOOP -= 1
1301                KEY.COUNT -= 1
1302             END
1303          NEXT DISPLAY.LOOP

Comments?

_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

-
te Stanton
lstan Systems Ltd
Kelmarna Ave, Herne Bay, Auckland 1011, New Zealand
one: + 64 9 360 5310  Mobile: + 64 21 400 486
ail: k...@walstan.com
_____________________________________________
-Users mailing list
-us...@listserver.u2ug.org
tp://listserver.u2ug.org/mailman/listinfo/u2-users
_____________________________________________
-Users mailing list
-us...@listserver.u2ug.org
tp://listserver.u2ug.org/mailman/listinfo/u2-users
_____________________________________________
-Users mailing list
-us...@listserver.u2ug.org
tp://listserver.u2ug.org/mailman/listinfo/u2-users
_____________________________________________
-Users mailing list
-us...@listserver.u2ug.org
tp://listserver.u2ug.org/mailman/listinfo/u2-users
_____________________________________________
-Users mailing list
-us...@listserver.u2ug.org
tp://listserver.u2ug.org/mailman/listinfo/u2-users
______________________________________________
-Users mailing list
-us...@listserver.u2ug.org
tp://listserver.u2ug.org/mailman/listinfo/u2-users
_____________________________________________
-Users mailing list
-us...@listserver.u2ug.org
tp://listserver.u2ug.org/mailman/listinfo/u2-users
_____________________________________________
-Users mailing list
-us...@listserver.u2ug.org
tp://listserver.u2ug.org/mailman/listinfo/u2-users
_____________________________________________
-Users mailing list
-us...@listserver.u2ug.org
tp://listserver.u2ug.org/mailman/listinfo/u2-users
_____________________________________________
-Users mailing list
-us...@listserver.u2ug.org
tp://listserver.u2ug.org/mailman/listinfo/u2-users
_______________________________________________
2-Users mailing list
2-us...@listserver.u2ug.org
ttp://listserver.u2ug.org/mailman/listinfo/u2-users
______________________________________________
2-Users mailing list
2-us...@listserver.u2ug.org
ttp://listserver.u2ug.org/mailman/listinfo/u2-users

_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to