Perhaps this is not a revelation to many of you, but I did not realize
how _much_ faster it is to append items to a large array using <-1> vs.
an incrementing count, e.g. <n>. I was trying to speed up a program that
builds large arrays, and changed to the <-1> style append.

Wow [can I say that? this is a linux box, not MS-Vista; is "wow"
copyrighted yet?], huge improvement! (UV 10.1.4 pick flavor, intel cpu).
Of course, when using <-1> you need to check for nulls as appropriate,
but even adding after adding code to test for and handle appending a
null attribute this is still way faster.

Also, I think UV is optimized for AMs vs VMs, so that it pays to CONVERT
@VM TO @AM IN XXX, do your thing, then CONVERT @VM TO @AM IN XXX back
when done if you need VMs.

/Scott Ballinger
Pareto Corporation
Edmonds WA USA
206 713 6006


Here is a test program:

* dynamic array append test
* 03-08-07 asb

MAX = 20000
T1 = TIME()
XX = ""
FOR N = 1 TO MAX
  XX<-1> = N
  IF MOD(N,1000) EQ 0 THEN PRINT ".":
NEXT N
PRINT
PRINT TIME()-T1

T1 = TIME()
XX = ""
FOR N = 1 TO MAX
  XX<N> = N
  IF MOD(N,1000) EQ 0 THEN PRINT ".":
NEXT N
PRINT
PRINT TIME()-T1

T1 = TIME()
XX = ""
FOR N = 1 TO MAX
  XX<-1> = N
  IF MOD(N,1000) EQ 0 THEN PRINT ".":
NEXT N
PRINT
PRINT TIME()-T1


And here is the result:

>RUN BP SB
....................
0.0197
....................
5.6788
....................
0.0205
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to