This is more of an "old trick".

The reason that <-1> is so much faster is because using <-1> just
appends to an already existing string in memory. Where using <n> will
cause an entirely new string to be created and the old one thrown away
(to be eventually garbage collected). The process gets slower & slower
as each successive string becomes larger and larger.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Scott Ballinger
Sent: Friday, 9 March 2007 11:10 AM
To: [email protected]
Subject: [U2] old dog, new tricks

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





DISCLAIMER:
Disclaimer.  This e-mail is private and confidential. If you are not the 
intended recipient, please advise us by return e-mail immediately, and delete 
the e-mail and any attachments without using or disclosing the contents in any 
way. The views expressed in this e-mail are those of the author, and do not 
represent those of this company unless this is clearly indicated. You should 
scan this e-mail and any attachments for viruses. This company accepts no 
liability for any direct or indirect damage or loss resulting from the use of 
any attachments to this e-mail.
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to